Reputation: 3307
I need to search for places and get results in a specified language.
The Places API has a language support when using a url query.
I would like to use the Android
API (Places Autocomplete
), meaning something like
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi
.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
mBounds, mPlaceFilter, "pl");
Clearly, the last parameter ("pl" stands for Polish) can't be used as this method doesn't exists..
I thought about using the filter, but it doesn't seem to have this option.
Any ideas? Thx.
Edit
Seems like the results are returned in the same language that the query was written, which is actually pretty cool:)
Upvotes: 1
Views: 818
Reputation: 11
Setting the default locale to the app's language seems to do the trick. I added the code below in my base activity class, which all activities extend. It might also be fine just to add it in your class that extends Application (if you don't have a "switch language live" option)
Locale locale = new Locale(languageCode);
Locale.setDefault(locale);
Note: I set the locale before calling super.onCreate(savedInstanceState)
Upvotes: 1