我是 android 编程的新手,我想问一下如何开始使用 google places API。我已经在 https://developers.google.com/places/training/basic-place-search 上搜索了很多而且我无法获得清晰而有条理的结果。请帮忙。
最佳答案
要从 Java/Android 应用程序使用 Places API,您需要执行以下操作:
- 从 Google 获取 Places API key 。
- 使用 Android SDK 中包含的类似于 Apache 的
HttpClient
类的东西向 API 发出 HTTP 请求。 JSON 格式的数据比 XML 更容易处理。 - 获取响应字符串,使用
JSONObject
类对其进行解析,然后深入到这些JSONObject
和JSONArray
对象以获取您想要的数据。
在 Google 上搜索“google places api android”会出现一些教程,例如这个:http://karnshah8890.blogspot.com/2013/03/google-places-api-tutorial.html
您可能还对 this third-party offering on GitHub 这样的图书馆感兴趣,它将 HTTP API 调用包装到更友好的面向对象的界面中。
关于android - 如何使用 google places API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20863173/