OpenCycleCompass / ocyco-app-android

Android App for OpenCycleCompass
GNU General Public License v3.0
6 stars 1 forks source link

Check for Google Play Services APK #63

Closed rleh closed 8 years ago

rleh commented 9 years ago

Beispiel: (https://developer.android.com/google/gcm/client.html)

private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
...
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    mDisplay = (TextView) findViewById(R.id.display);

    context = getApplicationContext();

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

// You need to do the Play Services APK check here too.
@Override
protected void onResume() {
    super.onResume();
    checkPlayServices();
}

/**
 * Check the device to make sure it has the Google Play Services APK. If
 * it doesn't, display a dialog that allows users to download the APK from
 * the Google Play Store or enable it in the device's system settings.
 */
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;
}

This issue was migrated from GitLab. Original author is Raphael Lehmann. It was originally created 2015-03-14 23:45.

rleh commented 9 years ago

http://stackoverflow.com/questions/24494598/android-check-for-google-play-services-apk-when-using-gamehelper:

You don't HAVE to check for the presence of Google Play Services, but Google recommend that you do: http://developer.android.com/google/play-services/setup.html#ensure If you do not check, and Google Play Services is not installed, Android will prompt the user to install Google Play Services.
rleh commented 9 years ago

Es sollten folglich am beste nur die Google Location Services mittels com.google.android.gms:play-services-location:7.8.0 eingebunden werden.

Wenn GMS nicht auf dem gerät installiert ist (isGooglePlayServicesAvailable()) solle bestenfalls die AOSP Location Api verwendet werden.

rleh commented 8 years ago

See #114