pause/minimize android app

478 views
Skip to first unread message

_com_

unread,
Sep 2, 2014, 4:43:18 PM9/2/14
to kivy-...@googlegroups.com
Hi,

I use the on_pause method to support pausing my app on android. That works fine with the menu and task button. But the back button seams to stop the app. Now I try to overwrite the beavior of the back button. I catch the keyboard event but now i have no clue how to tell the app to pause/minimize.
Any ideas?

Thanks!

Damien Moore

unread,
Sep 2, 2014, 10:31:14 PM9/2/14
to kivy-...@googlegroups.com
Take a look at:


specifically on_keyboard and on_pause members of the derived App class

_com_

unread,
Sep 3, 2014, 8:36:45 AM9/3/14
to kivy-...@googlegroups.com
The App has the same problem. If you hit the android back button in the main menu, the app is closed and switching back to the app causes the app to reload (kivy loading screen). If you use the android menu/task button everything works fine (app is pausing, returning to the app needs no loading screen).
How can i manually force the app to pause? I found the stop() method in App class, but the the app needs to reaload on resume after calling that. Isn’t it possible to manually call the mechanism used by android menu/task button?

Alexander Taylor

unread,
Sep 3, 2014, 9:15:35 AM9/3/14
to kivy-...@googlegroups.com
You need to look up the normal android api call to send your app activity to the back of the stack (which pauses it, as oppised to closing the activity), then call it with pyjnius. It's something very simple but I don't remember the details.

_com_

unread,
Sep 3, 2014, 10:28:52 AM9/3/14
to kivy-...@googlegroups.com
Thanks, got it working with jnius:

    def hook_keyboard(self, window, key, *largs):
        if key == 27:
            PythonActivity = jnius.autoclass('org.renpy.android.PythonActivity')
            Intent = jnius.autoclass('android.content.Intent')
            intent = Intent(Intent.ACTION_MAIN)
            intent.addCategory(Intent.CATEGORY_HOME)
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
           
            currentActivity = jnius.cast('android.app.Activity', PythonActivity.mActivity)
            currentActivity.startActivity(intent)
            return True
Reply all
Reply to author
Forward
0 new messages