How i can check whether play store is available in the mobile device and whether it is the latest a version or not from my app ,before calling an in app service?
You can check if the Google Play Services are avaiable on the device like this:
int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
switch(errorCode) {
case ConnectionResult.SUCCESS:
// Google Play Services installed and up to date
break;
case ConnectionResult.SERVICE_MISSING:
// Google Play services is missing on this device.
break;
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
// The installed version of Google Play services is out of date.
break;
case ConnectionResult.SERVICE_DISABLED:
// The installed version of Google Play services has been disabled on this device.
break;
case ConnectionResult.SERVICE_INVALID:
// The version of the Google Play services installed on this device is not authentic.
break;
case ConnectionResult.DATE_INVALID:
// The device date is likely set incorrectly.
break;
}
You can also display an appropriate error message if there is a problem:
int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
if(GooglePlayServiceUtil.showErrorDialogFragment(errorCode, getActivity(), REQUEST_CODE)) {
// There was a problem. Error dialog was shown.
} else {
// Everything is fine. Error dialog was not shown.
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments