Ich verwende GoogleApiClient in meiner Android-App und es kommt zu einem Absturz, wenn meine App fortgesetzt wird.Anwendung stürzt beim Fortsetzen der Verwendung von GoogleApiClient ab
Der Code sieht wie folgt aus:
MainActivity Unterschrift:
public class MainActivity : AppCompatActivity, GoogleApiClient.IOnConnectionFailedListener, Android.Gms.Location.ILocationListener
OnCreate
protected override async void OnCreate(Bundle bundle)
{
App.Initialize();
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
await InitializeGoogleApis();
}
Google API-Initialisierung
private async Task InitializeGoogleApis()
{
// Construct api client and request for required api's
googleApiClientBuilder = new GoogleApiClient.Builder(this)
.AddApi(LocationServices.API)
.EnableAutoManage(this, this);
// Connect to google play services
googleApiClient = await googleApiClientBuilder
.BuildAndConnectAsync();
// Request location api and set common properties
googleLocationRequest = new LocationRequest()
.SetPriority(LocationRequest.PriorityHighAccuracy)
.SetInterval(1000)
.SetFastestInterval(1000);
// Set location changed listener
await LocationServices.FusedLocationApi.RequestLocationUpdatesAsync(googleApiClient, googleLocationRequest, this);
}
onResume und OnDestroy:
protected override void OnResume()
{
base.OnResume();
}
protected override async void OnDestroy()
{
base.OnDestroy();
if (googleApiClient != null)
await LocationServices.FusedLocationApi.RemoveLocationUpdatesAsync(googleApiClient, this);
}
Ich habe alle Ausnahmen eingeschaltet, aber es is no exception description
Die App immer abstürzt, wenn ich versuche fortzusetzen. Wenn es abstürzt, wird es in den Hintergrund gestellt und wenn ich versuche, es wieder aufzunehmen, funktioniert es perfekt. Ich forcebly GoogleApiClient stoppen und neu zu initialisieren es wieder in meinem OnRestart Funktion