【发布时间】:2015-10-28 12:58:45
【问题描述】:
我想在我在 Xamarin 中开发的 Android 应用程序中实现类似 this 的东西,但找不到 GoogleApiClient 所在的命名空间。有人可以帮忙吗?
【问题讨论】:
标签: android google-maps xamarin google-api
我想在我在 Xamarin 中开发的 Android 应用程序中实现类似 this 的东西,但找不到 GoogleApiClient 所在的命名空间。有人可以帮忙吗?
【问题讨论】:
标签: android google-maps xamarin google-api
GoogleApiClient 在 Android.Gms.Common.Apis 命名空间中。
该命名空间位于“Xamarin.GooglePlayServices.Basement”程序集中,但您不直接安装它。
因此,假设您在进行一些 Android 位置/地图开发时尝试访问它,请安装此 nuget:
Xamarin Google Play Services - Location
用于 Google Play 服务的 Xamarin.Android 绑定 - 位置
移动应用程序的独特功能之一是位置 意识。移动用户随身携带他们的设备,并且 为您的应用添加位置感知功能可为用户提供更多的上下文 经验。 Google Play 服务中可用的位置 API 有助于通过自动化将位置感知添加到您的应用程序中 位置跟踪、地理围栏和活动识别。
要安装 Xamarin Google Play 服务 - 位置,请运行以下命令 包管理器控制台中的命令
PM> Install-Package Xamarin.GooglePlayServices.Location
使用子句:
using Android.Gms.Common.Apis;
代码:
var foo = GoogleApiClient ();
【讨论】:
除了RobertN的回答,好像还有naming/namespace changes in 27.0.0.0。
所以这里有一个可能有帮助的例子:
GoogleApiClient api = new GoogleApiClient.Builder (Application.Context, this, this)
.AddApi (Android.Gms.Location.LocationServices.API)
.Build ();
上述代码中this表示实现了以下接口:
【讨论】:
应该注意,“Install-Package Xamarin.GooglePlayServices.Location”命令也适用于更新 Xamarin.GooglePlayServices。如果您尝试使用 UI 更新组件,它总是会失败。
【讨论】: