1

I want to make an app, when user open my app user will get their current location in my app and while user change their location it will also update after some specific time. I got solution of changed location while user change their location but i need to show current location of user while user open my app.

Arpit Prajapati
  • 367
  • 2
  • 16
  • 1
    Possible duplicate of [How do I get the current GPS location programmatically in Android?](http://stackoverflow.com/questions/1513485/how-do-i-get-the-current-gps-location-programmatically-in-android) – Shabbir Dhangot Feb 13 '17 at 06:44
  • what have you done so far ? Please add the code. – tahsinRupam Feb 13 '17 at 06:44

1 Answers1

4
googleMap.setMyLocationEnabled(true);
Location myLocation = googleMap.getMyLocation();

These are the the key lines to get current location.

for more info ,refer these tutorials: android show current location on map using google maps api

and how to get current location in google map android

Community
  • 1
  • 1
Liya
  • 568
  • 7
  • 28
  • not working. It shows Latitude:0.0 and Longitude:0.0 – Arpit Prajapati Feb 13 '17 at 10:43
  • But that links worked fine for me. then refer these links also, http://javapapers.com/android/get-current-location-in-android/ , http://clover.studio/2016/08/09/getting-current-location-in-android-using-location-manager/ – Liya Feb 14 '17 at 04:03
  • 1
    It works [android show current location on map using google maps api](http://javapapers.com/android/android-show-current-location-on-map-using-google-maps-api/) when i run it on different devices.Thanks – Arpit Prajapati Feb 14 '17 at 05:19