Maybe look similar with many questions posted here but none of old solutions don't work anymore. I tested all and in all cases crash my application.
I need to display current user location in my MapFragment.
I try to use this code found on net:
LocationManager locationManager;
locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(provider);
locationManager.requestLocationUpdates(provider, 20000, 0, this);
but my application crash. He stop running before displaying anything.
The problem is here :
Location location = locationManager.getLastKnownLocation(provider);
locationManager.requestLocationUpdates(provider, 20000, 0, this);
What I do wrong? This is my first android application.