1

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

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193

2 Answers2

1

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;
Androider
  • 2,884
  • 5
  • 28
  • 47
  • That's a cool thing but is there any way we can add the lib sort of thing so its automatically support my maps? – Muhammad Umar May 25 '13 at 06:21
  • @MuhammadUmar check the link in my answer. – Raghunandan May 25 '13 at 06:24
  • @MuhammadUmar if you have updated your adt to rev 22 check this link http://stackoverflow.com/questions/16636039/java-lang-classnotfoundexception-after-changing-nothing-in-the-project-but-upgra/16636127#16636127 – Raghunandan May 25 '13 at 06:26
  • @MuhammadUmar have you updated you adt plugin to rev 22. i suspect that is the case and that is causing classdef not found error – Raghunandan May 25 '13 at 06:31
0
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

Raghunandan
  • 132,755
  • 26
  • 225
  • 256