I want to get my location if phone is connected to Wifi or mobile network. However if phone is on mobile network things dont run as wanted. Nothing is happening until if i enable GPS. Can i get location without enabling GPS or i have to do that ? And if GPS is must, how could i warn user to enable GPS ?
private void setUpMap() {
// TODO Auto-generated method stub
mMap.setMyLocationEnabled(true);
LocationManager manager = (LocationManager)getActivity().getSystemService(FragmentActivity.LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = manager.getBestProvider(criteria, true);
myLocation = manager.getLastKnownLocation(provider);
latitude = myLocation.getLatitude();
longitude = myLocation.getLongitude();
LatLng latlng = new LatLng(latitude, longitude);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 14));
}