How does Android place autocomplete get the search location list by default
I implemented the local autocomplete function in my application, and wrote the search keyword in EditText to obtain the results according to the search location keyword. Here is the code for searching placeautocomplete activity
int PLACE_AUTOCOMPLETE_REQUEST_CODE = 1;
try {
Intent intent =
new
PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
.build(this);
startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
} catch (GooglePlayServicesRepairableException e) {
} catch (GooglePlayServicesNotAvailableException e) {
}
When the activity startup list is blank
What I want is - places that have been searched should be displayed as super applications when the activity starts
resolvent:
You must keep the autocomplete results in the internal application store (shared preferences, database..) or anywhere you want. Basically, you need to implement the UI yourself. I don't think you can customize placeautocomplete.intentbuilder as needed
>Implement API calls for autocomplete Google Places (we're working on this)
@GET("/maps/api/place/autocomplete/json")
Call<GoogleAutocompleteResponse> getAutoCompleteSearchResults(@Query("key") String apiKey,
@Query("input") String searchTerm,
@Query("location") String location,
@Query("radius") long radius);
>Execute call (on enter click or ontextchange)
public List<GooglePlaceAutocompleteGeoModel> getAutoCompleteSearchResults(String searchTerm, LatLng center, long radius) {
Call<GoogleAutocompleteResponse> call = googlePlacesRestApiService.getAutoCompleteSearchResults(API_KEY, searchTerm, getLocationStringFrom(center), radius);
try {
GoogleAutocompleteResponse autocompleteResponse = call.execute().body();
List<GooglePlaceAutocompleteGeoModel> autocompleteResponsePredictions = autocompleteResponse.getPredictions();
//Here are your Autocomplete Objects
return autocompleteResponsePredictions;
} catch (IOException e) {
L.e("Error on Google Autocomplete call: " + e.getMessage());
}
return new ArrayList<>();
}
>In your application, adhere to the results of Google autocompleteresponse and implement logic to display the results in the UI or fill in the listview