• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Google Places API Android filter according to place type

Gel06

Newbie
Dec 23, 2016
18
0
I am trying to filter nearby places specifically hospitals. I'm using Google Places API for Android. My code below doesn't have any errors, but it doesn't show any hospitals.

Java:
List<String> filters = new ArrayList<>();
filters.add(String.valueOf(Place.TYPE_HOSPITAL));
PlaceFilter placeFilter = new PlaceFilter(false, filters);

PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
                .getCurrentPlace(mGoogleApiClient, placeFilter);
        result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
            @Override
            public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
                for (PlaceLikelihood placeLikelihood : likelyPlaces) {

                    mMap.addMarker(new MarkerOptions()
                            .position(placeLikelihood.getPlace().getLatLng())
                            .title((String) placeLikelihood.getPlace().getName())
                            .snippet((String) placeLikelihood.getPlace().getPhoneNumber()));
                }
                likelyPlaces.release();
            }
        });
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones