I am trying to show current location on google map on andorid.I have written some cod to do that.But when i launch the app on Map Activity it does not show current location on google map.But when i tap on current location button on google map then it shows the current location.Please why it does not show current location automatically?
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(true);
Log.i("MAP", "AFTER LOCATION");
LocationManager locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String bestProvider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(bestProvider);
if (location != null) {
onLocationChanged(location);
}
locationManager.requestLocationUpdates(bestProvider,0, 0, this);