![](/img/trans.png)
[英]Google Play In-App Review API. How to check if the user has rated the app?
[英]How to check if user has Google Play Services enabled
我正在使用Android Studio编写应用程序,并且希望该应用程序检查设备的用户是否已启用Google Play服务,但是我不知道如何执行此操作,有人可以帮忙吗?
您应该使用以下代码:
private boolean checkPlayServices () {
GoogleApiAvailability gApi = GoogleApiAvailability.getInstance();
int resultCode = gApi.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (gApi.isUserResolvableError(resultCode)) {
gApi.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Toast.makeText(this, getResources().getString(R.string.toast_playservices_unrecoverable), Toast.LENGTH_LONG).show();
finish();
}
return false;
}
return true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.