-
-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
questionFurther information is requestedFurther information is requested
Description
The code works on mac, but on an Android device it seems that the service and main app don't exchange (respond to) messages from one another.
Because if I don't send messages between them and just start service and push notification on a time interval it works.
Below is my code.
main.py:
from oscpy.client import OSCClient
from oscpy.server import OSCThreadServer
SERVICE_NAME = '{packagename}.Service{servicename}'.format(
packagename='clientsandorders.com.clientsandorders',
servicename='Taskreminder'
)
class MainApp(MDApp):
def build(self):
kv = Builder.load_file("main.kv")
self.start_service()
self.server = server = OSCThreadServer()
server.listen(
address=b'localhost',
port=3002,
default=True,
)
server.bind(b'/ping_response', self.ping_response)
self.client = OSCClient(address=b'localhost', port=3000)
return kv
def ping_response(self):
self.client.send_message(b'/push_up', [])
And here's the service code:
from time import sleep
from oscpy.server import OSCThreadServer
from oscpy.client import OSCClient
from plyer import notification
from plyer.utils import platform
from jnius import autoclass
CLIENT = OSCClient(address='localhost', port=3002)
def push_up():
if platform == 'android':
notification.notify(title='Test', message='This is a test message')
else:
print('Service works')
def ping_activity():
CLIENT.send_message(b'/ping_response', [])
if __name__ == '__main__':
SERVER = OSCThreadServer()
SERVER.listen(address='localhost', port=3000, default=True)
SERVER.bind(b'/push_up', push_up)
PythonService = autoclass('org.kivy.android.PythonService')
PythonService.mService.setAutoRestartService(True)
while True:
sleep(10)
ping_activity()
Expected behaviour is for service to ping the main app on a specific time interval, then get a response (with some data in the future) and to push a notification with plyer.
logcat shows no errors.
Many thanks in advance!
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested