android - 如何使用 google places API

标签 android google-places-api

我是 android 编程的新手,我想问一下如何开始使用 google places API。我已经在 https://developers.google.com/places/training/basic-place-search 上搜索了很多而且我无法获得清晰而有条理的结果。请帮忙。

最佳答案

要从 Java/Android 应用程序使用 Places API,您需要执行以下操作:

  1. 从 Google 获取 Places API key 。
  2. 使用 Android SDK 中包含的类似于 Apache 的 HttpClient 类的东西向 API 发出 HTTP 请求。 JSON 格式的数据比 XML 更容易处理。
  3. 获取响应字符串,使用 JSONObject 类对其进行解析,然后深入到这些 JSONObjectJSONArray 对象以获取您想要的数据。

在 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/

相关文章:

android - 如何修复 Xamarin Forms Android 构建中的 "ConvertResourcesCases"?

android - 获取可调整大小的应用程序小部件尺寸(或绕过它)

google-maps - 获取特定地址组件的 place_id

android - 从 URL 在 Google Maps v2 Android 上设置标记图标

google-places-api - Google Places API 自动完成 我们可以重复使用 session token 吗?

android - 您必须为 TextView 提供资源 ID

android - 使用 actionBarSherlock 仅显示选项卡

android - 如何解决 Key 中的 FireBase 数据库禁止字符或解决方法

android - 整洁架构 : share same models/entities with different layers

javascript - 如何将谷歌自动完成地点限制为N个国家?