I am new to android i have implemented auto complete for map places. it is working fine when giving input without spaces, but when i am giving input with spaces results are not showing in android
This is following code I am using for auto complete.
fromlocation.addTextChangedListener(new AutoCompleteTextWatcher(fromlocation,"from",fromPlacesDetailsList,fromPlacesAdapter,getApplicationContext(),googleRestGateway));
For text watcher:
@Override
public void afterTextChanged(Editable s)
{
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,int after)
{
}
@Override
public void onTextChanged(CharSequence placeInput, int start, int before, int count)
{
String place = placeInput.toString();
if(place!=null && (place.length()>0 & place.length()<10))
{
{
new AutoCompleteTask(placeDetails,adapter,appContext,googleRestGateway,textView).execute(place);
}
}
}
I am getting the placesDetailsList
in both cases i.e; with spaces given and also without spaces this is code on how i am parsing the response.
protected void onPostExecute(List<HashMap<String, String>> placesDetailsList)
{
//Log.d(LogActivityTagNames.AUTO_COMPLETE_TASK, " Entered into onPostExecute() with " + placesDetailsList.toString());
String[] from = new String[] { "description"};
int[] to = new int[] { android.R.id.text1 };
placesAdapter = new SimpleAdapter(ctx, placesDetailsList, android.R.layout.simple_dropdown_item_1line, from, to)
{
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View view = super.getView(position, convertView, parent);
TextView text1 = (TextView) view.findViewById(android.R.id.text1);
text1.setTextColor(Color.BLACK);
return view;
}
};
autoTextView.setAdapter(placesAdapter);
}
This is the URL https://maps.googleapis.com/maps/api/place/autocomplete/json?sensor=true&input=kr+puram&types=geocode&key=AIzaSyD3nw5uC7ptOT6Kq57GJ6SvFyW3mHcWfaY
. The above code is working fine without spaces as input, but when I am giving spaces results are coming but they are not displaying in emulator.