You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Google Play services provide an ProviderInstaller.installIfNeeded() method that will ensure that the device that is secured against vulnerabilities and that the Security Provider is up to date.
Leverage this method in order to perform the check during the App's startup; the following cases need to be handled:
• If the device's Provider is successfully updated (or is already up-to-date), the method will return normally.
• If the device's Google Play services library is out of date, the method will throw an GooglePlayServicesRepairableException. The App can then catch this exception and show the user an appropriate dialog box to update Google Play services.
• If an error occurs, the method will throw a GooglePlayServicesNotAvailableException to indicate that it is unable to update the Provider. The App can then catch the exception and choose an appropriate course of action.
Secure Code
Add the following method to your top/first activity:
public void providerInstallerCheck(Context context) {
try {
// Checking if the ProviderInstaller is installed and updated
ProviderInstaller.installIfNeeded(context);
Toast.makeText(context, "Provider installed and updated!", Toast.LENGTH_LONG).show();
} catch (GooglePlayServicesRepairableException e) {
/* If the ProviderInstaller is installed but not updated
A popup asks the user to do a manual update of the Google Play Services
*/
e.printStackTrace();
GooglePlayServicesUtil.showErrorNotification(e.getConnectionStatusCode(), context);
Toast.makeText(context, "Provider it outdated. Please update your Google Play Service"
, Toast.LENGTH_LONG).show();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
/* If the ProviderInstaller is not installed but not updated
A popup redirects the user to the Google Play Services page on the Google PlayStore
and let the user download them.
*/
Dialog dialog = GooglePlayServicesUtil
.getErrorDialog(e.errorCode, this,
REQUEST_GOOGLE_PLAY_SERVICES_DOWNLOAD);
dialog.setCancelable(false);
dialog.show();
}
}
The text was updated successfully, but these errors were encountered:
The Google Play services provide an ProviderInstaller.installIfNeeded() method that will ensure that the device that is secured against vulnerabilities and that the Security Provider is up to date.
Leverage this method in order to perform the check during the App's startup; the following cases need to be handled:
• If the device's Provider is successfully updated (or is already up-to-date), the method will return normally.
• If the device's Google Play services library is out of date, the method will throw an GooglePlayServicesRepairableException. The App can then catch this exception and show the user an appropriate dialog box to update Google Play services.
• If an error occurs, the method will throw a GooglePlayServicesNotAvailableException to indicate that it is unable to update the Provider. The App can then catch the exception and choose an appropriate course of action.
Secure Code
Add the following method to your top/first activity:
The text was updated successfully, but these errors were encountered: