Skip to content

Instantly share code, notes, and snippets.

@dokinkon
Last active February 4, 2017 05:20
Show Gist options
  • Save dokinkon/8f6cb4dc29908979f09a235c66ee0898 to your computer and use it in GitHub Desktop.
Save dokinkon/8f6cb4dc29908979f09a235c66ee0898 to your computer and use it in GitHub Desktop.
檢查Play Service在裝置上的可用性 (Deprecated)
public class PlayServicesUtils {
public static boolean checkGooglePlayServices(final Activity activity) {
final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
switch (googlePlayServicesCheck) {
case ConnectionResult.SUCCESS:
return true;
case ConnectionResult.SERVICE_DISABLED:
case ConnectionResult.SERVICE_INVALID:
case ConnectionResult.SERVICE_MISSING:
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
activity.finish();
}
});
dialog.show();
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment