In my application, I need to check Google Play services version (which is installed in user\'s device). Is it possible ? And if yes, how can I do that? I searched Google but
I’ve run into the same problem this morning. And got it done by the advice from stan0. Thanks stan0.
Only one change is needed based on the sample code from https://developers.google.com/maps/documentation/android/map.
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the
// map.
if (mMap == null) {
FragmentManager mgr = getFragmentManager();
MapFragment mapFragment = (MapFragment)mgr.findFragmentById(R.id.map);
mMap = mapFragment.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
// The Map is verified. It is now safe to manipulate the map.
setUpMap();
}else{
// check if google play service in the device is not available or out-dated.
GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
// nothing anymore, cuz android will take care of the rest (to remind user to update google play service).
}
}
}
Besides, you need to add an attribute to your manifest.xml as:
And the value of "3225130" is taken from the google-play-services_lib that your project is using. Also, that value is residing in the same location of manifest.xml in google-play-services_lib.
Hope it will be of help.