Skip to content Skip to sidebar Skip to footer

Android: Calling Google Api .getplacebyid With Multiple Place_id's

In order to reduce the number of API calls, I'm trying to query place details by passing several place_ids at a time (up to 10). I haven't found any useful information beyond the

Solution 1:

It's a varargs argument. You call it like this:

Places.GeoDataApi.getPlaceById(mGoogleApiClient, 
        "placeId1", "placeId2", "placeId3");

More detail in this SO question: How does the Java array argument declaration syntax "..." work?

Solution 2:

Although I've read that String... can be passed as either a comma delimited string or a string array, for one reason or other, getPlaceById appears to require an array. When I use this code to prepare the place id parameter, it works fine:

    String search[] =new String[idsToSearch.size()];
    search= idsToSearch.toArray(search);

Post a Comment for "Android: Calling Google Api .getplacebyid With Multiple Place_id's"