comparison cagou/core/cagou_main.py @ 141:8a0019ce3632

core (android): service is now launched using pyjnius, as recommended in doc
author Goffi <goffi@goffi.org>
date Fri, 13 Apr 2018 18:58:14 +0200
parents 36fc269e2a32
children d276cfec38e8
comparison
equal deleted inserted replaced
140:8f33a7c09214 141:8a0019ce3632
70 Window.clearcolor = (1, 1, 1, 1) 70 Window.clearcolor = (1, 1, 1, 1)
71 71
72 72
73 if kivy_utils.platform == "android": 73 if kivy_utils.platform == "android":
74 # FIXME: move to separate android module 74 # FIXME: move to separate android module
75 kivy.support.install_android()
76 # sys.platform is "linux" on android by default 75 # sys.platform is "linux" on android by default
77 # so we change it to allow backend to detect android 76 # so we change it to allow backend to detect android
78 sys.platform = "android" 77 sys.platform = "android"
79 import mmap 78 import mmap
80 C.PLUGIN_EXT = 'pyo' 79 C.PLUGIN_EXT = 'pyo'
280 def __init__(self): 279 def __init__(self):
281 if bridge_name == 'embedded': 280 if bridge_name == 'embedded':
282 from sat.core import sat_main 281 from sat.core import sat_main
283 self.sat = sat_main.SAT() 282 self.sat = sat_main.SAT()
284 if sys.platform == 'android': 283 if sys.platform == 'android':
285 from android import AndroidService 284 from jnius import autoclass
286 service = AndroidService(u'Cagou (SàT)'.encode('utf-8'), u'Salut à Toi backend'.encode('utf-8')) 285 service = autoclass('org.goffi.cagou.cagou.ServiceBackend')
287 service.start(u'service started') 286 mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
287 argument = ''
288 service.start(mActivity, argument)
288 self.service = service 289 self.service = service
289 290
290 bridge_module = dynamic_import.bridge(bridge_name, 'sat_frontends.bridge') 291 bridge_module = dynamic_import.bridge(bridge_name, 'sat_frontends.bridge')
291 if bridge_module is None: 292 if bridge_module is None:
292 log.error(u"Can't import {} bridge".format(bridge_name)) 293 log.error(u"Can't import {} bridge".format(bridge_name))