android - How to invoke setCountry() to AutocompleteFilter Google place API? -
i implementing placeautocompletefragment auto complete of location. want restrict search specific country ( earlier use component=uk in url). how can achieve in below code.
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); placeautocompletefragment autocompletefragment = (placeautocompletefragment) getfragmentmanager().findfragmentbyid(r.id.place_autocomplete_fragment); autocompletefilter typefilter = new autocompletefilter.builder() .settypefilter(autocompletefilter.type_filter_regions) .build(); autocompletefragment.setfilter(typefilter); autocompletefragment.setonplaceselectedlistener(new placeselectionlistener() { @override public void onplaceselected(place place) { log.i(tag, "place: " + place.getname()); log.i(tag, "place: " + place.getid()); } @override public void onerror(status status) { log.i(tag, "place: " + status); } });
please help..
placeautocompletefragment autocompletefragment = (placeautocompletefragment) getfragmentmanager().findfragmentbyid(r.id.place_autocomplete_fragment); autocompletefilter typefilter = new autocompletefilter.builder() .settypefilter(place.type_country).setcountry("uk") .build(); autocompletefragment.setfilter(typefilter);
you need make ensure play version should compile 'com.google.android.gms:play-services:9.6.1'
Comments
Post a Comment