Error getting Location Android (GPS and Network)

前端 未结 2 2033
广开言路
广开言路 2020-12-22 05:17

I want to get the location in my APP using the following code:

public Location getLocation() {     

    boolean isGPSEnabled     = false;
    boolean isNetw         


        
相关标签:
2条回答
  • 2020-12-22 05:25

    If the device have not yet found a location, it will return null.

    I bet if your open Google Maps and let it locate you before opening your app, it will work as expected.

    See my answer to Location servise GPS Force closed. This is an example on how you can implement a callback to let you know as soon as a location is available.

    0 讨论(0)
  • 2020-12-22 05:26

    I think you have to trigger it by calling one of the .request... functions.

    0 讨论(0)
提交回复
热议问题