我尝试使用Google API开发一个程序,并使用xamarin
在android studio中,附近服务的最新版本是16.0.0,已于2018年10月更新
但是我在xamarin中找到的最新的nuget附近版本是60.1142.1,该版本于2018年3月更新,等于android studio中的11.4.2
如何在android studio中获取最新的NuGet附近版本? 因为我在使用11.4.2时遇到麻烦,因为它需要GoogleApiClient作为参数
public NearbyService()
{
Context = Application.Context;
ConnectionsClient = NearbyClass.Connections;
SetGoogleApiClient();
}
public void SetGoogleApiClient()
{
GoogleApiClient = new GoogleApiClient.Builder(Context)
.AddConnectionCallbacks(this)
.AddOnConnectionFailedListener(this)
.AddApi(NearbyClass.CONNECTIONS_API)
.Build();
if (!GoogleApiClient.IsConnected)
GoogleApiClient.Connect();
}
public void OnConnected(Bundle connectionHint)
{
NearbyConnections = new NearbyConnections();
ConnectionLifeCycleCallbackService = new ConnectionLifeCycleCallbackService(this, new PayloadCallbackService(this));
EndPointDiscoveryCallbackService = new EndPointDiscoveryCallbackService(this, ConnectionLifeCycleCallbackService);
}
public void OnConnectionFailed(ConnectionResult result)
{
if (!GoogleApiClient.IsConnected)
GoogleApiClient.Connect();
}
然后在我的MainActivity中,我将呼叫
protected override void OnRestart()
{
base.OnRestart();
if (NearbyService.GoogleApiClient != null && !NearbyService.GoogleApiClient.IsConnected)
NearbyService.GoogleApiClient.Connect();
}