How to put mobile application in Suspended state?
-
Hello everyone!
Recently I faced a problem with my mobile application (on Android). Normally in Android applications user can quit application by pressing Back navigation button when in a root screen. Also application can be suspended by pressing Home navigation button or switching to another application. I'd like Back button to act like Home button (i.e suspend application), but I don't know how. I tried the following:- Window::showMinimized() - it doesn't work in Android
- Window::hide() - it doesn't work in Android
<meta-data android:name="android.app.background_running" android:value="true"/>
- it doesn't change the behaviour- Qt.application.state - is readonly property
So the quistion is: How can I programatically trigger Home button or can put my application into suspended mode?
Thanks in advance.
-
I don't think this is possible at all. The key event comes from the OS and filters through your application.
I'm unsure if you can send such an event further along the os, without rooting.However it's not going to be something build in Qt, but something you'll have to use native code for
-
@J-Hilk
Thank you!
As I understand your answer, I can intercept events from navigation buttons, and for example prevent it from propogation to OS, but I can't change their default actions. The only action I may trigger without using some native code is application quit.Am I right?
-
@levolex
I'm actually not entirely sure what the underlying process is.For the "Back Button" you can catch that inside your application, because it's literally the
Qt::Key_Back
button and simply invokes QApplication::quit() if you don't catch it.From what I understand of android, the Home and Menu button are not designed to be processed by any application. Therefore no way to catch those events, without a rooted device.