简体   繁体   中英

Huawei P40 Google Play Services dialog

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM