Using Google Places API in Android

左心房为你撑大大i 提交于 2019-11-26 12:09:20

问题


I am trying to develop an app which can display the schools and airports in the locality. I found that using Google Places API is the way to go.

I have seen the documentation here... Can anyone explain how to use the API?


回答1:


New tutorial available

It appears that the original tutorial by Brian is now 404, so here is a link to the Google one in case people see this answer first.

https://developers.google.com/places/android-api/current-place-tutorial

When this article was first written this tutorial didn't exist.


Original:

You could try this tutorial (now 404): http://blog.brianbuikema.com/2010/08/android-development-part-1-using-googles-places-api-to-develop-compelling-location-based-mobile-applications/




回答2:


You can find a tutorial on the Places API in a J2SE environment, using the Google APIs Client Library for Java on my blog. It also includes a sample application in Github that might get you started.

If should be fairly easy to port to Android, as the Google APIs Client Library for Java is Android compatible.




回答3:


You will have to get familiar with HttpClient, HttpRequest, and HttpResponse if you're not already.

Very simply:
Step 1) build your uri with your api key and search terms as per google's syntax
Step 2) perform a post using that uri
Step 3) decode the response from the post

Happy coding :)




回答4:


The point is that you have to build the URL, create the HttpRequest and get the data in XML or JSON format. After that, you may parse this data to get the information you want. Most of people do it in each use, but I think the best option is to have an API for that purpose.

I have developed an API which builds the URL, connects and gets the data in a list of objects that represent places in a well structured OOP design. And everything happen in background in an AsyncTask, which returns the information through an interface/listener. https://github.com/perezdidac/google-places-api.




回答5:


see this link for Showing nearby places using Google Places API

try this




回答6:


Google places API which was provided as part of google play services is deprecated. Google provided new version of Places SDK for android.

The new version doesn't support place picker. You can migrate old code in your app to new version by following instructions documented here https://developers.google.com/places/android-sdk/client-migration

With new version, you can specify filters for results and fields to be present in the response. See below tutorial with examples to know how to use new places sdk for android, http://www.zoftino.com/google-places-sdk-for-android-tutorial



来源:https://stackoverflow.com/questions/3830149/using-google-places-api-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!