Using Google Places API in Android

醉酒当歌 提交于 2019-11-27 06:45:48

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/

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.

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 :)

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.

see this link for Showing nearby places using Google Places API

try this

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

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