kivy / plyer

Plyer is a platform-independent Python wrapper for platform-dependent APIs

Home Page:https://plyer.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can plyer.gps work when the application is minimized or running in the background?

killatonna1 opened this issue · comments

Can plyer.gps work and collect data from the GPS module when the android application is minimized or running in the background? If possible, are there implementation examples.

My code only works when the application is active. But for example, the requests library continues to send data in a collapsed mode. Most likely my problem is either with permissions or with the implementation.

Can anybody help?

buildozer.spec permissions

android.permissions = android.permission.INTERNET, FOREGROUND_SERVICE_LOCATION, ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION, ACCESS_BACKGROUND_LOCATION

My code:

import time
from jnius import autoclass

PythonService = autoclass('org.kivy.android.PythonService')
PythonService.mService.setAutoRestartService(True)
from plyer import gps


def get_gps_data():
    gps.configure(on_location=on_location)
    gps.start(1000, 0) 


def on_location(**kwargs):
    latitude = kwargs.get('lat')
    longitude = kwargs.get('lon')
    print(f'coords: {latitude}, {longitude}')
if __name__ == '__main__':
    get_gps_data()
    try:
        while True:
            pass  
    except:
        print('service stop')
commented

👋 Sorry to hear you are having difficulties; Kivy unites a number of different technologies, so developing apps can be temperamental.

We try to use GitHub issues only to track work for developers to do to fix bugs and add new features to this project. This issue is being closed, because it doesn't describe a bug in this project.

There is a mailing list and a Discord channel to support Kivy users debugging their own systems, which should be able to help. They are linked in the ReadMe.

Of course, if it turns out you have stumbled over a bug in this project, we do want to hear about it here. The support channels should be able to help you craft an appropriate bug report.