简体   繁体   中英

Android Google Play services

I developed an Android app using Google Play Service, to use GCM service.

In MainActivity check the device for a compatible Google Play services APK before accessing Google Play services features. In the app this check is done in two places: in the main activity's onCreate() method, and in its onResume() method. like this:

if (checkPlayServices()) {
    // If this check succeeds, proceed with normal processing.
    // Otherwise, prompt user to get valid Play Services APK.
    ...
}

and :

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;
}

My Problem is : in some country users can't download Google play service from GooGlePlay, so they can't use my app.

is it possible to put google play services on app ? or put it on another server and prompt user to download Google Play Services from new location ?

any other solution are welcome.

Best Regards,

Even with Google Play Services libraries, you will still need it installed on your device. GooglePlayServicesUtil is specifically for checking Google Play Services (if installed, version, etc).

Call isGooglePlayServicesAvailable() to check if you have it installed and if so, what version. If the resutCode is not a success, then call GooglePlayServicesUtil.getErrorDialog() and pass it the error code. This should prompt the user to install Google Play Services.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM