delight-im / Android-SimpleLocation

Utility class for easy access to the device location on Android
Apache License 2.0
200 stars 75 forks source link

Always updating the last known location rather than the current one. #3

Closed Abhinab01 closed 9 years ago

Abhinab01 commented 9 years ago

Hello mwaclawek, I am very grateful that you have made this wonderful library available to everyone and it is pretty awesome.

But currently im facing some issues with getting the current location, as the old known location is only getting updated most of the times... And in many devices im only getting (0,0) coordinates...

Is there any way I can correct it and make it update the location to the current one every-time asked for and eliminate the (0,0) coordinate results?...

I really need your help and I shall always be grateful to you for the same... Please help...

ocram commented 9 years ago

Thanks for your kind feedback!

What's your code that isn't really working yet? Did you include the call to beginUpdates()?

Otherwise, if the default interval between new location updates (10 minutes) does not work for you, you can pass a custom interval (in milliseconds) to the constructor: https://github.com/delight-im/Android-SimpleLocation/blob/568773416017e7c515f330f5c0f083831b3a2f66/Source/src/im/delight/android/location/SimpleLocation.java#L161

Does that help?

Abhinab01 commented 9 years ago

Thanks a lot for your kind response... Yes I figured out that I was not calling beginUpdates(); but like you said, to change the default update time I need to pass a custom interval (in milliseconds) to the constructor, but HOW? I'm using your .jar file in my library, How can I edit that? Please Help... I really need it... :(

Thank You Again... :) On Apr 14, 2015 3:12 AM, "Marco" notifications@github.com wrote:

Thanks for your kind feedback!

What's your code that isn't really working yet? Did you include the call to beginUpdates()?

Otherwise, if the default interval between new location updates (10 minutes) does not work for you, you can pass a custom interval (in milliseconds) to the constructor:

https://github.com/delight-im/Android-SimpleLocation/blob/568773416017e7c515f330f5c0f083831b3a2f66/Source/src/im/delight/android/location/SimpleLocation.java#L161

Does that help?

— Reply to this email directly or view it on GitHub https://github.com/delight-im/Android-SimpleLocation/issues/3#issuecomment-92509586 .

ocram commented 9 years ago

Using the JAR is fine, it's possible without changing any library code:

Right now, you're calling the constructor like this:

location = new SimpleLocation(this);

You just have to replace that call with the following one:

location = new SimpleLocation(this, false, false, 5000);

... to request a new location every 5 seconds. This will drain the battery more than the default interval, of course. You have to try and see what works for you.

If you had the second parameter of the constructor set to true like this:

location = new SimpleLocation(this, true);

... then keep that parameter as well and just add the two false and 5000.

Please report if that worked :)

Abhinab01 commented 9 years ago

Thanks a lot.... I'll let you know if it works... :)

On 17 April 2015 at 22:44, Marco notifications@github.com wrote:

Using the JAR is fine, it's possible without changing any library code:

Right now, you're calling the constructor like this:

location = new SimpleLocation(this);

You just have to replace that call with the following one:

location = new SimpleLocation(this, false, false, 5000);

... to request a new location every 5 seconds. This will drain the battery more than the default interval, of course. You have to try and see what works for you.

If you had the second parameter of the constructor set to true like this:

location = new SimpleLocation(this, true);

... then keep that parameter as well and just add the two false and 5000.

Please report if that worked :)

— Reply to this email directly or view it on GitHub https://github.com/delight-im/Android-SimpleLocation/issues/3#issuecomment-94029839 .

Abhinab01 commented 9 years ago

The edits you suggested, are working like a charm...! But there's a little problem that my Mobile and some other phones keeps updating the same location again and again until I restart my phone, but on many other phones it does updates every 5 seconds as you suggested....

Is there a way I can correct it?

I do call location.beginUpdates(); before I start the rest of the program, but still I receive the same locations until restarted...

Thank You. :)

On 17 April 2015 at 22:55, Abhinab Das abhinabdas001@gmail.com wrote:

Thanks a lot.... I'll let you know if it works... :)

On 17 April 2015 at 22:44, Marco notifications@github.com wrote:

Using the JAR is fine, it's possible without changing any library code:

Right now, you're calling the constructor like this:

location = new SimpleLocation(this);

You just have to replace that call with the following one:

location = new SimpleLocation(this, false, false, 5000);

... to request a new location every 5 seconds. This will drain the battery more than the default interval, of course. You have to try and see what works for you.

If you had the second parameter of the constructor set to true like this:

location = new SimpleLocation(this, true);

... then keep that parameter as well and just add the two false and 5000.

Please report if that worked :)

— Reply to this email directly or view it on GitHub https://github.com/delight-im/Android-SimpleLocation/issues/3#issuecomment-94029839 .

ocram commented 9 years ago

Thanks, apparently, there's no bug here and everything is working as intended.

If you continue to have problems with some devices that use the same location again and again (what does that mean, exactly?) please check your integration and check if GPS is enabled on the device.

Should you need more help even after debugging your integration, please open a separate issue here. Thank you!

Abhinab01 commented 9 years ago

Ok I'll check it, Thanks a lot anyways.. :) On Apr 22, 2015 12:37 AM, "Marco" notifications@github.com wrote:

Closed #3 https://github.com/delight-im/Android-SimpleLocation/issues/3.

— Reply to this email directly or view it on GitHub https://github.com/delight-im/Android-SimpleLocation/issues/3#event-286534541 .