Próbuję skorzystać z usługi Google Play w mojej aplikacji na Androida. Jak mówi dokument Google, przed użyciem musimy sprawdzić, czy Google API jest dostępne. Szukałem jakiegoś sposobu, żeby to sprawdzić. Oto co mam:
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
Ale kiedy przechodzę do strony Google Api GooglePlayServicesUtil, https://developers.google.com/android/reference/com/google/android/gms/common/GooglePlayServicesUtil
Uważam, że wszystkie funkcje są przestarzałe . Na przykład metoda
GooglePlayServicesUtil.isGooglePlayServicesAvailable (wycofane)
A Google zaleca użycie:
GoogleApiAvailability.isGooglePlayServicesAvailable .
Jednak podczas próby skorzystania z GoogleApiAvailability.isGooglePlayServicesAvailable pojawia się komunikat o błędzie:
