Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check Google Mobile Services enable in device or not?

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.

like image 903
elify Avatar asked Oct 27 '25 07:10

elify


2 Answers

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;
    }
like image 75
Bilawal muzaffar Avatar answered Oct 28 '25 21:10

Bilawal muzaffar


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
like image 43
m0skit0 Avatar answered Oct 28 '25 22:10

m0skit0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!