locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
try {
location = locationManager.getLastKnownLocation(provider);
}
catch (Exception e)
{
}
if(location==null) {
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
}
if (location != null) {
double lat = location.getLatitude();
double longg = location.getLongitude();
mMap.moveCamera( CameraUpdateFactory.newLatLngZoom(new LatLng(lat,longg) , 14.0f) );
startService(new Intent(MainActivity.this, MyService.class));
ismarkervisible = true;
} else {
Toast.makeText(MainActivity.this, "Device Failed To Fetch Lat Long", Toast.LENGTH_LONG).show();
}