Huawei P40 Google Play Services dialog

Viewed 1937

I want to run my app on Huawei P40. This phone is not supporting Google Play Services. So I made APK for AppGallery. App is working fine (only Google Maps cant be opened) but as I change some tabs or content, some system dialog will popup with message "MyApp won't run without Google Play services, which are not supported by your device." This dialog can be closed on tap but it will reappear everytime I switch Activity or Fragment.

Is there any way how to disable this message? I implemented HMS to my Gradle files.

1 Answers

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!");
    }
});

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

Related