问题
All of the Android APIs for Google Place searches return predictions, and these are not as accurate or as complete as the Place Search web service. Though predictions usually deliver the desired place, I've bumped into scenarios where they don't. I want to use the Android API as a primary search tool, but offer the user a search button that delivers more complete results (like those returned by the web service).
I've validated that I have a working web api-key with this url: https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=47.725977,-122.047113&keyword=home%20depot&rankBy=distance&key=my-key
In a test app, I called this exact url using HttpURLConnection, and I also use an app-specific API key to validate that I can use GoogleApiClient to to get location information (lattitude and longitude). Here's a screen shot of the result:
I've been unable to successfully call a Google Place web service from my app, regardless of keys I provide (including an Unrestricted key). Google doesn't seem to want us to use web services from an app, though there are a couple of StackOverflow questions that imply it's possible.
My questions are (1) is it technically feasible to call Google Places WS from an app, and (2) if not, is there an alternative in the Android API that I'm overlooking that would achieve the detailed search results I need?
来源:https://stackoverflow.com/questions/40570594/using-google-places-web-service-in-an-android-app