Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle GooglePlayServicesRepairableException and GooglePlayServicesNotAvailableException

I read the official docs and it confuses me. What is difference between GooglePlayServicesRepairableException and GooglePlayServicesNotAvailableException. When they are thrown? How to handle these errors? How to show a dialog to user, where he can enable/update/install the services. e.t.c.

private void startLocationPicker() {
        try {
            new PlacePicker.IntentBuilder().build(this);
        } catch (GooglePlayServicesRepairableException e) {

        } catch (GooglePlayServicesNotAvailableException e) {

        }
    }
like image 398
Semyon Avatar asked May 25 '16 21:05

Semyon


1 Answers

As mentioned in the GooglePlayServicesRepairableException docs:

GooglePlayServicesRepairableExceptions are special instances of UserRecoverableExceptions which are thrown when Google Play Services is not installed, up-to-date, or enabled. In these cases, client code can use getConnectionStatusCode() in conjunction with getErrorDialog(android.app.Activity, int, int) to provide users with a localized Dialog that will allow users to install, update, or otherwise enable Google Play services.

GooglePlayServicesNotAvailableException also has an error code which can be used with getErrorDialog(), although I'd encourage you to look over all of the methods available in GoogleApiAvailability.

like image 142
ianhanniballake Avatar answered Sep 22 '22 04:09

ianhanniballake