Android Application Google Map GetLastLocation

28 Views Asked by At

I developed an application using android studio. I used Google Maps in my application. When opening Google maps first I want the last location of the user using the code block below.

     locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener);
     Location lastlocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

But user last location return null. How can I fix that problem?

0

There are 0 best solutions below