简体   繁体   中英

How to require updated play services and add “This app won't run unless you update Google Play services”

I have created an application that uses the latest play services (7.8). This app uses the new barcode reader and it is vital to the application's functionality. As I was looking for an answer for this question I've found out that when using the Maps API the application forces the user to have updated play services. Now I am not able to achieve that.

I'm using genymotion as my emulator and installed play services with an outdated version. It runs the app fine but barcode scanner isn't running. Log also says:

Didn't find class "com.google.android.gms.vision.client.DynamiteNativeBarcodeDetectorCreator" 

I have already added this in the application tag in AndroidManifest:

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

Hangouts and other google apps also have that block when you open the app that forces the user to install an updated play services first before using the application.

Sorry for my bad English. Thank you for the help!

Maybe I didn't search hard enough. There is an instruction in the android developer guide's site

I only added this code in my activity's onResume() method:

Dialog errorDialog = GoogleApiAvailability.getInstance().getErrorDialog(this,
            GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(getApplicationContext()),
                    REQUEST_CODE_RECOVER_PLAY_SERVICES);
    if (errorDialog != null)
        errorDialog.show();

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