Last active
February 4, 2017 05:20
-
-
Save dokinkon/8f6cb4dc29908979f09a235c66ee0898 to your computer and use it in GitHub Desktop.
檢查Play Service在裝置上的可用性 (Deprecated)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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