Error getting Location Android (GPS and Network)

前端 未结 2 2037
广开言路
广开言路 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.

提交回复
热议问题