![](/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.