1

I am trying to get accurate latitude and Longitude on my Android Kivy app. Modules like geocoder use IP address, but in my testing that has been super far off when using mobile data. I need some code that works in a kivy apk. It seems like plyer is the way to go, but the docs for it aren't clear how to use it and I couldn't figure it out. I looked around but couldn't find any indication on how to use plyer at all. Does anyone know how to use plyer to get GPS on android? Some python3 code to get lat and lng (not within a few feet. I really only need within a city block or two) would be amazing! Thanks in advance!

Also, if you know of another way to get accurate location data without relying only on wifi or IP geolocating, that would also be appreciated.

UPDATE and clarification:

The gps example ( https://github.com/kivy/plyer/tree/master/examples ) is working on my device, but I don't understand the code. What I understand (or I think I understand): It is looping and constantly updating the widget with the right information.I don't, however, understand what lines of code is actually setting it up and what is getting the coordinates. Is it even possible to use these commands to just get latitude and longitude to a variable? I don't need it to constantly update the coordinates, I just need them once and then assign that to a variable. Is there a method in plyer that I can call and have it return lat and lng? If so, how do I set it up?

Thrasherop
  • 71
  • 2
  • 11
  • On their github page there are examples for some of their modules. There is also a gps example. [Plyer Github Examples](https://www.github.com/kivy/plyer/tree/master/examples). Have a look at it and if you struggle, just update your question with your problem and write a comment, then I will have a look at it. – MisterNox May 18 '20 at 06:01
  • @MisterNox Okay. That code seems to work fine, but I don't understand whatss happening. What I understand (or I think I understand): It is looping and constantly updating the widget with the right information. – Thrasherop May 20 '20 at 05:17
  • I don't, however, understand what lines of code is actually setting it up and what is getting the coordinates. Is it even possible to use these commands to just get latitude and longitude to a variable? I don't need it to constantly update the coordinates, I just need them once. Can you help me out a bit here? Is there a method in plyer that I can call and have it return lat and lng? – Thrasherop May 20 '20 at 05:20
  • This example shows you everything you ask me now. You have a start and stop function. Write your own function which includes these two functions to get the variable. You can set the time it runs to get it only for a short period. The example stores the lat and long values as well only in a variable ( the kivy Stringproperty). Then the Property is used to update a label. Please show some effort and write down a first try, if it is not working it is a way easier to show you whats wrong. – MisterNox May 21 '20 at 09:22

1 Answers1

-1

To me plyer would need permission from the user before it gets its current location and most of them(GPS) usually gives longituyand latitude

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 05 '22 at 12:23
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32401238) – 0sVoid Aug 08 '22 at 21:06