Reputation: 73753
I just updated my app to the new google play services v4.0 and apparently my device does not yet have it.
now I check in my app if google play service is available
int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
if(result == ConnectionResult.SUCCESS){
Intent i = new Intent(context,LocationActivity.class);
i.putExtra("stationId", stationId);
i.putExtra("messageId", messageId);
context.startActivity(i);
}else{
mError.handleGooglePlayServices(result);
}
and it does not pass that so it goes to my handleGooglePlayService
method which looks like this
public void handleGooglePlayServices(int result) {
switch(result){
case ConnectionResult.SERVICE_MISSING:
GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_MISSING_CODE);
break;
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_UPDATE_CODE);
break;
case ConnectionResult.SERVICE_DISABLED:
GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_DISABLED_CODE);
break;
case ConnectionResult.SIGN_IN_REQUIRED:
ConnectionResult conn3 = new ConnectionResult(
ConnectionResult.SIGN_IN_REQUIRED, null);
try {
conn3.startResolutionForResult(this,
GOOGLE_PLAY_SERVICE_SIGN_IN_CODE);
} catch (SendIntentException e) {
e.printStackTrace();
}
break;
case ConnectionResult.INVALID_ACCOUNT:
ConnectionResult conn6 = new ConnectionResult(
ConnectionResult.INVALID_ACCOUNT, null);
try {
conn6.startResolutionForResult(this,
GOOGLE_PLAY_SERVICE_INVALID_ACCT_CODE);
} catch (SendIntentException e) {
e.printStackTrace();
}
break;
case ConnectionResult.RESOLUTION_REQUIRED:
ConnectionResult conn7 = new ConnectionResult(
ConnectionResult.RESOLUTION_REQUIRED, null);
try {
conn7.startResolutionForResult(this,
GOOGLE_PLAY_SERVICE_RESOLUTION_CODE);
} catch (SendIntentException e) {
e.printStackTrace();
}
break;
}
}
and when I step through the code it gives me a result of 2
which is SERVICE_VERSION_UPDATE_REQUIRED
but I dont get a dialog that lets me go get the update.
I was following the guild for how to set up google play services and it say just to do what I am doing
It is up to you choose the appropriate place in your app to do the following steps to check for a valid Google Play services APK. For example, if Google Play services is required for your app, you might want to do it when your app first launches. On the other hand, if Google Play services is an optional part of your app, you can do these checks if the user navigates to that portion of your app:
Query for the status of Google Play services on the device with the isGooglePlayServicesAvailable() method, which returns a result code.
If the result code is SUCCESS, then the Google Play services APK is up-to-date, and you can proceed as normal.
If the result code is SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or SERVICE_DISABLED, then call getErrorDialog() to display an error message to the user, which allows the user to download the APK from the Google Play Store or enable it in the device's system settings.
What am I doing wrong?
Upvotes: 2
Views: 2907
Reputation: 1006704
getErrorDialog()
returns a Dialog
. You still need to show it, such as via a DialogFragment
. It does not show itself.
Upvotes: 1