Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'isGooglePlayServicesAvailable'(this) is deprecated

I'm following a tutuorial to use google location services. So, I'm trying to get location using Google API service. But I got isGooglePlayServicesAvailable(this) is deprecated error. Can anyone help. Thanks

Below is my code for checking if Play services exist on device:

private boolean checkPlayServices(){     int resultCode = GooglePlayServicesUtil             .isGooglePlayServicesAvailable(this);     if(resultCode != ConnectionResult.SUCCESS){         if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)){             GooglePlayServicesUtil.getErrorDialog(resultCode, this,                     PLAY_SERVICES_RESOLUTION_REQUEST).show();         }else {             Toast.makeText(getApplicationContext(),                     "This device is not supported", Toast.LENGTH_LONG)                     .show();             finish();         }         return false;     }     return true; } 
like image 715
Muhamad Hishamudin Avatar asked Jan 07 '17 14:01

Muhamad Hishamudin


1 Answers

Use isGooglePlayServicesAvailable instead

GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) 
like image 54
Linh Avatar answered Oct 10 '22 08:10

Linh