Display the error dialog of Google Play Service is not installed and redirect user to it
android, google-cloud-messaging
Solution
Something like this :
if(!isGooglePlayServicesAvailable()) {
GooglePlayServicesUtil.getErrorDialog(9999, this, RQS_GooglePlayServices).show();
}
9999 is the request code (a random integer) used in `onActivityResult()`.
Problem
Hello I am trying to use the `GCM` in android application where it is require to check whether use has `Google Play Service` installed or not. For this I have coded but I don't how to handle the situation when user do not have `Google Play Service` installed. Is there any in built a way to give prompt user to install the `Google Play Service` and redirect it to play store to install it. ``` /** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ public static boolean checkPlayServices(Context mContext) { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(mContext); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, (Activity)mContext,Constants.PLAY_SERVICES_RESOLUTION_REQUEST).show(); } return false; } return true; } ``` // here check whether device has google play service installed // if it is installed then register the device with the GCM // otherwise redirect user to play store to install it. ``` if(Utils.checkPlayServices(getActivity())) { new RegisterGCMDeviceAsynTask(new TaskCompleteListener() { @Override public void onTaskCompleted(String result) { new TeemWurkAsyncTask(new TaskCompleteListener() { @Override public void onTaskCompleted(String result) { Logger.d(TAG, result); } }, Constants.LOGIN_API_CALL).execute(""); } }).execute(); } else { // display the dialog that device do not have Google Play Service installed. } ```