That because there is no application with package name 'org.kivy.touchtracer' on your android device.
XR <
x-ro...@web.de> wrote:
Here is a complete example for the kivy launcher on Android.
Hopefully my problem gets more clear.
It works like it is described here:
http://kivy.org/planet/2014/01/building-a-background-application-on-android-with-kivy/# -*- coding: utf-8 -*-
__version__ = '1.0'
import kivy
kivy.require('1.0.7')
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from android import AndroidService
from jnius import autoclass, cast
class TestApp(App):
def build(self):
self.service = None
self.app_started = False
root = Widget()
btn = Button(text='start app', size_hint=(.5, .1),pos_hint={'center_x': .5, 'center_y': .5})
btn.bind(on_press=self.start_app)
root.add_widget(btn)
return btn
def on_pause(self):
if not self.app_started:
service = AndroidService('Service', 'service is running')
service.start('Hello From Service')
self.service = service
return True
def on_resume(self):
if self.service:
self.service.stop()
self.service = None
self.app_started = False
return True
def start_app(self,instance):
self.app_started = True
PythonActivity = autoclass('org.renpy.android.PythonActivity')
Intent = autoclass('android.content.Intent')
Context = autoclass('android.content.Context')
activity = cast('android.app.Activity', PythonActivity.mActivity)
#manager = autoclass('android.content.pm.PackageManager')
# or:
manager = activity.getPackageManager()
intent = manager.getLaunchIntentForPackage("org.kivy.touchtracer")
intent.addCategory(Intent.CATEGORY_LAUNCHER)
activity.startActivity(intent)
if __name__ == "__main__":
TestApp().run()
# -*- coding: utf-8 -*-
from jnius import autoclass, cast
from kivy.core.audio import SoundLoader
import time
def play_sound():
sound = SoundLoader.load("Bubamara.MP3")
sound.play()
time.sleep(1)
sound.stop()
if __name__ == '__main__':
# to see, if the service really gets started
# play a soundfile.
# place it in the service directory
#play_sound()
PythonActivity = autoclass('org.renpy.android.PythonActivity')
Intent = autoclass('android.content.Intent')
Context = autoclass('android.content.Context')
activity = cast('android.app.Activity', PythonActivity.mActivity)
# this line causes the error in kivys logfile:
# jnius.jnius.JavaException: Unable to find a None method!
manager = autoclass('android.content.pm.PackageManager')
# this line crashes kivy
# no error gets thrown
#manager = activity.getPackageManager()
intent = manager.getLaunchIntentForPackage("org.kivy.touchtracer")
intent.addCategory(Intent.CATEGORY_LAUNCHER)
activity.startActivity(intent)
Does someone know, if my problem is a generall restriction of what is possible with services? Or is it a bug or missing feature in kivy or pyjnius?
Or do I have to code it different?
Thanks for any help,
XR
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
kivy-users+...@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.