GooglePlayServicesUtil.getErrorDialog is null

后端 未结 4 1358
失恋的感觉
失恋的感觉 2020-12-05 06:27

I\'m using ACRA (arca.ch) to generate automatic error reports.

I just released a new version of my app using Google Maps Android API v2. I\'m getting an error repor

4条回答
  •  执笔经年
    2020-12-05 07:14

    Based on Rahim's code, I add the capability of preventing the user to dismiss the Google Play Services dialog (by hitting the back button) and continue using the app without Google Play Services installed:

    private void checkGooglePlayServicesAvailable() {
        int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        if (status != ConnectionResult.SUCCESS) {
            if (GooglePlayServicesUtil.isUserRecoverableError(status)) {
                Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, 0);
                dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialogInterface) {
                        MainActivity.this.finish();
                    }
                });
                dialog.show();
            } else {
                Toast.makeText(this, "This device is not supported.", Toast.LENGTH_LONG).show();
                finish();
            }
        }
    }
    

提交回复
热议问题