2

アプリを新しい 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されますが、更新を取得できるダイアログが表示されません。

私はグーグルプレイサービスをセットアップする方法についてギルドに従っていましたが、それは私がやっていることをするだけだと言っています

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.

私は何を間違っていますか?

4

1 に答える 1

1

getErrorDialog()を返しますDialog。などを介して表示する必要がありますDialogFragment。それ自体は表示されません。

于 2013-10-31T20:12:07.583 に答える