Skip to content Skip to sidebar Skip to footer

Non-static Method Isgoogleplayservicesavailable And Geterrordialog Cannot Be Referenced From A Static Context

I am writing this code and it shows the error non-static method GoogleApiAvailability.isGooglePlayServicesAvailable(Context context) and GoogleApiAvailability.getErrorDialog (Activ

Solution 1:

Nurlan has already pointed the right answer.

Replace your method

protectedvoidIsPlayServicesAvailable() {
    int resultCode = GoogleApiAvailability.isGooglePlayServicesAvailable(this);

    if (resultCode == ConnectionResult.SUCCESS){
        msgText.setText("isGooglePlayServicesAvailable SUCCESS");
    } else {
        GoogleApiAvailability.getErrorDialog(this, resultCode, 1).show();
    }
}

by

protectedvoidIsPlayServicesAvailable() {
    int resultCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this);

    if (resultCode == ConnectionResult.SUCCESS){
        msgText.setText("isGooglePlayServicesAvailable SUCCESS");
    } else {
        GoogleApiAvailability.getInstance().getErrorDialog(this, resultCode, 1).show();
    }
}

Solution 2:

by googling, this link says: staticisGooglePlayServicesAvailable(Context ctx) is deprecated, use non- staticisGooglePlayServicesAvailable(Contex ctx). (And there is public static GoogleApiAvailability getInstance () for you ;) )

Post a Comment for "Non-static Method Isgoogleplayservicesavailable And Geterrordialog Cannot Be Referenced From A Static Context"