I have to check if google services are active on the device. How can I check it? Looking just play services is enough?
I need this check for Huawei services.
final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (status != ConnectionResult.SUCCESS) {
Log.e(TAG, GooglePlayServicesUtil.getErrorString(status));
return false;
} else {
Log.i(TAG, GooglePlayServicesUtil.getErrorString(status));
return true;
}
You should use GoogleApiAvailability API. GooglePlayServicesUtil API is deprecated, don't use it.
Java:
public boolean isGooglePlayServicesAvailable(final Context context) {
return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS;
}
Kotlin:
fun Context.isGooglePlayServicesAvailable(): Boolean =
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With