Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample for how to use the Google Play Services dynamic security provider to keep the SSL library that the app will use to up date.
package com.mycompany.myapp.app;
import android.app.Application;
import android.content.Intent;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.security.ProviderInstaller;
import com.google.android.gms.security.ProviderInstaller.ProviderInstallListener;
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
upgradeSecurityProvider();
}
private void upgradeSecurityProvider() {
ProviderInstaller.installIfNeededAsync(this, new ProviderInstallListener() {
@Override
public void onProviderInstalled() {
}
@Override
public void onProviderInstallFailed(int errorCode, Intent recoveryIntent) {
GooglePlayServicesUtil.showErrorNotification(errorCode, MainApplication.this);
}
});
}
}
@cutiko

This comment has been minimized.

Copy link

@cutiko cutiko commented Nov 2, 2017

Greetings

This has solved an issue for me, thanks. I have a doubt. I'm using this library:

compile 'com.google.android.gms:play-services-base:11.0.0'

Is that the correct library?

@miguelnfuertesc

This comment has been minimized.

Copy link

@miguelnfuertesc miguelnfuertesc commented Jul 27, 2018

I used this one

implementation 'com.google.android.gms:play-services-safetynet:15.0.1'

and everything worked as expected.

@noamtamim

This comment has been minimized.

Copy link

@noamtamim noamtamim commented Sep 11, 2018

GooglePlayServicesUtil.showErrorNotification(...) is now deprecated; should be replaced with
GoogleApiAvailability.getInstance().showErrorNotification(...).

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Dec 14, 2018

@noamtamim But it gives this error: no suitable method found for showErrorNotification(int,MainActivity)
GoogleApiAvailability.getInstance().showErrorNotification(errorCode, MainActivity.this); when you update it like you mentioned

@Belka1000867

This comment has been minimized.

Copy link

@Belka1000867 Belka1000867 commented Jan 4, 2019

@noamtamim But it gives this error: no suitable method found for showErrorNotification(int,MainActivity)
GoogleApiAvailability.getInstance().showErrorNotification(errorCode, MainActivity.this); when you update it like you mentioned

You should use it like this :

    @Override
    public void onProviderInstallFailed(int i, Intent intent) {
        GoogleApiAvailability.getInstance().showErrorNotification(MainApplication.this, i);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment