In My Device( Karbon A 21 Mobile Phone) , When Google Play Services
are not installed, my location
object is null
and while Google Play Services
installed, it returns correct location.
I know that I can check if Google Play Services
are installed using-GooglePlayServicesUtil.isGooglePlayServicesAvailable(this)
.
But then Can I install Google Play Services
pragmatically or should I ask user to install it manually?
Why other App shows location even if Google Play Services
are not installed?
Am I doing something wrong in my code. See code below.
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setCostAllowed(true);
provider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(provider);