Reputation: 11782
I have added google maps v2
. They use Google play services
. It seems from the rating that most of the users don't have updated Google play services thus getting crashes when they try to open the application..
Is there any way that we can make part of code the lib of google play service so they won't get crash...
Would love to find out any solution
Upvotes: 1
Views: 247
Reputation: 133560
public static int isGooglePlayServicesAvailable (Context context)
Verifies that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client.
Returns status code indicating whether there was an error. Can be one of following in ConnectionResult: SUCCESS, SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID.
Check the developer site under the topic Check for Google Play Services
https://developer.android.com/training/location/retrieve-current.html
Upvotes: 0
Reputation: 2804
If user doesn't have Google play services
you can show dialog to get it
// Getting Google Play availability status
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
//there are other "status" values as well, you can check according to your need
// Showing status
if(status!=ConnectionResult.SUCCESS){ // Google Play Services are not available
int requestCode = 10;
ialog dialog = GooglePlayServicesUtil.getErrorDialog(status, getActivity(), requestCode);
dialog.show();
}else{ // Google Play Services are available
// get map and play with it
}
where ConnectionResult
is:
import com.google.android.gms.common.ConnectionResult;
Upvotes: 1