本文介绍了华为P40 Google Play服务对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Huawei P40AppGallery."MyApp won't run without Google Play services, which are not supported by your device."ActivityFragment
Huawei P40AppGallery."MyApp won't run without Google Play services, which are not supported by your device."ActivityFragment
GradleHMS
HMSGradle

推荐答案

该弹出式窗口通常是由于代码中包含以下方法而发生的

That pop-up usually occurs due to having following methods in code

GoogleApiAvailability.makeGooglePlayServicesAvailable
GoogleApiAvailability.showErrorDialogFragment
GoogleApiAvailability.getErrorDialog

为了克服这个问题,采用如下所示的控件应该会有所帮助,并且适用于我的情况

In order to overcome this, having a control like below should be helpful and works on my case

GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();

int errorCode = googleApiAvailability.isGooglePlayServicesAvailable(this);

googleApiAvailability.makeGooglePlayServicesAvailable(this);
googleApiAvailability.showErrorNotification(this, errorCode);
googleApiAvailability.showErrorDialogFragment(this, errorCode, 100);

Dialog errorDialog = googleApiAvailability.getErrorDialog(this, errorCode, 100);
errorDialog.show();
errorDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
    @Override
    public void onDismiss(DialogInterface dialog) {
        Log.d(TAG, "Play pop-up has been dismissed!");
    }
});

或者,也可以使用isGooglePlayServicesAvailable方法并处理其返回状态SUCCESS,SERVICE_MISSING,SERVICE_UPDATING,SERVICE_VERSION_UPDATE_REQUIRED,SERVICE_DISABLED,SERVICE_INVALID

Alternatively, it is also possible to utilize isGooglePlayServicesAvailable method and handle its return states SUCCESS, SERVICE_MISSING, SERVICE_UPDATING, SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID

这篇关于华为P40 Google Play服务对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!