How do I get the current GPS location programmatically in Android?

前端 未结 22 2599
梦谈多话
梦谈多话 2020-11-21 04:42

I need to get my current location using GPS programmatically. How can i achieve it?

22条回答
  •  半阙折子戏
    2020-11-21 04:57

    GoogleSamples has verbose example using latest FusedLocationProviderApi. Unfortunately the most upvoted answers are out of date.

    Follow the below examples to implement Location Services using FusedLocationProviderApi

    https://github.com/googlesamples/android-play-location/tree/master/LocationUpdates

    https://github.com/googlesamples/android-play-location/blob/master/LocationUpdates/app/src/main/java/com/google/android/gms/location/sample/locationupdates/MainActivity.java

提交回复
热议问题