I am trying to use Google Play Service in my Android app. As Google document says, we need to check if the Google API is available before using it. I have searched some way to check it. Here is what I got:
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;
}
But when I go to Google Api GooglePlayServicesUtil page,
https://developers.google.com/android/reference/com/google/android/gms/common/GooglePlayServicesUtil
I find all functions are deprecated. For example, the method
GooglePlayServicesUtil.isGooglePlayServicesAvailable (deprecated)
And Google recommends to use:
GoogleApiAvailability.isGooglePlayServicesAvailable.
However, when I try to use GoogleApiAvailability.isGooglePlayServicesAvailable, I get the error message:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…