我想在我的Android应用程序中实现类似this的内容,我在Xamarin中开发但无法找到GoogleApiClient
所在的命名空间。有人可以帮忙吗?
答案 0 :(得分:11)
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 ();
答案 1 :(得分:4)
除了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 ();
在上面的代码中,意味着实现了以下接口:
答案 2 :(得分:0)
应该注意的是命令&#34; Install-Package Xamarin.GooglePlayServices.Location&#34;也适用于更新Xamarin.GooglePlayServices。如果您尝试使用UI更新组件,它将始终失败。