Skip to content Skip to sidebar Skip to footer

Location Returns Null

I am writing an Android app that returns longitude and latitude, however location holds a Null value. Please see if you can see why, Its been bugging me all day. Code below: public

Solution 1:

If the GPS has not ever gotten a location since the device was booted, the location object will be null. One thing you can do is attempt to get a GPS location and a network location, and check to two to see if either of them are good (or which one is better) and use that location.

Solution 2:

If you're using the emulator, then see here for advice on setting up the emulator to provide a location. If you're testing it on your device, it may be because you've never had a gps location on it. Try using the Google maps application before testing your app.

Post a Comment for "Location Returns Null"