更新时间:2023-01-04 23:32:21
该弹出式窗口通常是由于代码中包含以下方法而发生的
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