Muhammad Ahmed AbuTalib Muhammad Ahmed AbuTalib - 4 months ago 59
Android Question

Checking for google play services

It drives me crazy how important documentation is often overlooked in the google docs. I would have plucked out my hair if I wasn't bald already.

private void checkGooglePlayServices() {
int errorCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this);
boolean isErrorResolvable = GoogleApiAvailability.getInstance().isUserResolvableError(errorCode);

if (isErrorResolvable) {
GoogleApiAvailability.getInstance().getErrorDialog(this, errorCode, REQUEST_CODE_GOOGLE_PLAY_SERVICES).show();
} else {
if (errorCode == ConnectionResult.SUCCESS) {

The above code displays a Dialog box which says has a button reading get google play services:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);


now what should I do here ? How should I direct the user to the play store to get an update for the playservices? I deem
to be of use here, but I am not sure how to go about this.

please aid me.


You can use this code to open Google Play Service Page on App Store:

try {
  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE)));
} catch (android.content.ActivityNotFoundException anfe) {
  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("" + GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE)));