Hello, I'm trying to use the GCM application in android, where I need to check whether the use of Google Play Service installed or not. For this, I encoded, but I canβt cope with a situation where the user does not have Google Play Service .
Is there any built-in way to give the operator the ability to install the Google Play Service and redirect it to play to install it.
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; }
// check here if the Google Play device is installed. // if it is installed, then register the device using GCM // otherwise redirect the user to play in the 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 {
source share