gpt4 book ai didi

android - 如果用户需要更新他们的 google play 服务如何处理

转载 作者:行者123 更新时间:2023-11-29 01:48:45 26 4
gpt4 key购买 nike

我刚刚将我的应用程序更新到新的 google play 服务 v4.0,显然我的设备还没有它。

现在我检查我的应用程序是否可用 google play 服务

int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
if(result == ConnectionResult.SUCCESS){
Intent i = new Intent(context,LocationActivity.class);
i.putExtra("stationId", stationId);
i.putExtra("messageId", messageId);
context.startActivity(i);
}else{
mError.handleGooglePlayServices(result);
}

它没有通过,所以它转到我的 handleGooglePlayService看起来像这样的方法

public void handleGooglePlayServices(int result) {
switch(result){
case ConnectionResult.SERVICE_MISSING:
GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_MISSING_CODE);
break;
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_UPDATE_CODE);
break;
case ConnectionResult.SERVICE_DISABLED:
GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_DISABLED_CODE);
break;
case ConnectionResult.SIGN_IN_REQUIRED:
ConnectionResult conn3 = new ConnectionResult(
ConnectionResult.SIGN_IN_REQUIRED, null);
try {
conn3.startResolutionForResult(this,
GOOGLE_PLAY_SERVICE_SIGN_IN_CODE);
} catch (SendIntentException e) {
e.printStackTrace();
}
break;
case ConnectionResult.INVALID_ACCOUNT:
ConnectionResult conn6 = new ConnectionResult(
ConnectionResult.INVALID_ACCOUNT, null);
try {
conn6.startResolutionForResult(this,
GOOGLE_PLAY_SERVICE_INVALID_ACCT_CODE);
} catch (SendIntentException e) {
e.printStackTrace();
}
break;
case ConnectionResult.RESOLUTION_REQUIRED:
ConnectionResult conn7 = new ConnectionResult(
ConnectionResult.RESOLUTION_REQUIRED, null);
try {
conn7.startResolutionForResult(this,
GOOGLE_PLAY_SERVICE_RESOLUTION_CODE);
} catch (SendIntentException e) {
e.printStackTrace();
}
break;
}
}

当我单步执行代码时,结果为 2这是 SERVICE_VERSION_UPDATE_REQUIRED但我没有看到让我去获取更新的对话框。

我一直在关注如何设置 google play 服务的公会,它说只是做我正在做的事情

It is up to you choose the appropriate place in your app to do the following steps to check for a valid Google Play services APK. For example, if Google Play services is required for your app, you might want to do it when your app first launches. On the other hand, if Google Play services is an optional part of your app, you can do these checks if the user navigates to that portion of your app:

Query for the status of Google Play services on the device with the isGooglePlayServicesAvailable() method, which returns a result code.
If the result code is SUCCESS, then the Google Play services APK is up-to-date, and you can proceed as normal.
If the result code is SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or SERVICE_DISABLED, then call getErrorDialog() to display an error message to the user, which allows the user to download the APK from the Google Play Store or enable it in the device's system settings.

我做错了什么?

最佳答案

getErrorDialog() 返回一个 Dialog。您仍然需要显示它,例如通过 DialogFragment。它不显示自己。

关于android - 如果用户需要更新他们的 google play 服务如何处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19715677/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com