Change Language Of Google Places Autocomplete Prediction

- 1 answer

I'm using google map and google places API in my android application. I have a problem with Autocomplete prediction, I'm trying to search a Persian address,but I get result in English. I get primary text of result in Persian as well, but problem is in secondary text(Country and city name), that is English Always; Like this:

خیابان چارمردون، Iran, Tehran

I tried many ways to fix this issue, and when i changed my phone language to Persian, Results showed in Persian. Do anyone know how i can fix it?

This is my Autocomplete Filter:

AutocompleteFilter provideAutoCompleteFilter() {
    return new AutocompleteFilter.Builder()

This is my Adapter:

public class PlaceArrayAdapter extends ArrayAdapter<PlaceArrayAdapter.PlaceAutoComplete> implements Filterable {

    private static final String TAG = "PlaceArrayAdapter";
    private GoogleApiClient mGoogleApiClient;
    private AutocompleteFilter mPlaceFilter;
    private LatLngBounds mBounds;
    private ArrayList<PlaceAutoComplete> mResultList;
    private LayoutInflater inflater;

    public PlaceArrayAdapter(Context context, int resource, LatLngBounds bounds,
                             AutocompleteFilter filter) {
        super(context, resource);
        mBounds = bounds;
        mPlaceFilter = filter;
        inflater = LayoutInflater.from(getContext());

    public void setGoogleApiClient(GoogleApiClient googleApiClient) {
        if (googleApiClient == null || !googleApiClient.isConnected()) {
            mGoogleApiClient = null;
        } else {
            mGoogleApiClient = googleApiClient;

    public int getCount() {
        return mResultList.size();

    public PlaceAutoComplete getItem(int position) {
        return mResultList.get(position);

    public Filter getFilter() {
        Filter filter = new Filter() {
            protected FilterResults performFiltering(CharSequence constraint) {

                FilterResults results = new FilterResults();
                if (constraint != null) {
                    mResultList = getPredictions(constraint);

                    if (mResultList != null) {
                        results.values = mResultList;
                        results.count = mResultList.size();

                return results;

            protected void publishResults(CharSequence constraint, FilterResults results) {
                if (results != null && results.count > 0) {
                    // The API returned at least one result, update the data.
                } else {
                    // The API did not return any results, invalidate the data set.
        return filter;

    private ArrayList<PlaceAutoComplete> getPredictions(CharSequence constraint) {

        if (mGoogleApiClient != null) {

            Log.i(TAG, "Executing autocomplete query for -----> " + constraint);

            PendingResult<AutocompletePredictionBuffer> results = Places.GeoDataApi
                    .getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
                            mBounds, mPlaceFilter);

            // Wait for predictions, set the timeout.
            AutocompletePredictionBuffer autocompletePredictions = results
                    .await(60, TimeUnit.SECONDS);

            final Status status = autocompletePredictions.getStatus();
            if (!status.isSuccess()) {
                Log.e(TAG, "Error getting place predictions -----> " + status
                return null;

            Log.i(TAG, "Query completed. Received -----> " + autocompletePredictions.getCount()
                    + " predictions.");
            Iterator<AutocompletePrediction> iterator = autocompletePredictions.iterator();
            ArrayList resultList = new ArrayList<>(autocompletePredictions.getCount());
            while (iterator.hasNext()) {
                AutocompletePrediction prediction =;
                resultList.add(new PlaceAutoComplete(prediction.getPlaceId(),
            // Buffer release
            return resultList;

        Log.e(TAG, " -----> Google API client is not connected.");
        return null;

    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.auto_complete_text_view,parent,false);
        TextView tv = viewGroup.findViewById(;
        return viewGroup;

    public class PlaceAutoComplete {

        public CharSequence placeId;
        public CharSequence description;

        PlaceAutoComplete(CharSequence placeId, CharSequence description) {
            this.placeId = placeId;
            this.description = description;

        public String toString() {
            return description.toString();


I got it, The problem fixed by changing the application language, using the below code:

    Configuration config = getBaseContext().getResources().getConfiguration();
    Locale locale = new Locale("fa"); // <---- your target language
    config.locale = locale;

Maybe it's not the true way, but it worked!