0

I need to turn our Qt-Android App into a kind of Kiosk-App so the App wont close anymore if the user presses The home, back or recent apps button. Our App will be displayed on all kinds of TVs or tablets and it should just not be exitable by a user who isnt allowed to exit it.

The back Button was pretty easy to handle actually

bool Application::notify(QObject* object, QEvent* event)
{

...

#ifndef Q_OS_ANDROID
if (event->type() == QEvent::KeyPress) {
    QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
    if (keyEvent->key() == Qt::Key_Back)
    {
        qDebug() << "back key got pressed!";
        keyEvent->accept();
        return true;
    }
}
#endif // Q_OS_ANDROID

...

}

this works for the Back Button.

My main problem is The Home and the Recent Apps button presses are not sent to the application. Is there ANY way to get those signals?

greetings Georg

GeKo1990
  • 3
  • 1
  • You might be able to achieve this using the Qt Android Extras module: https://forum.qt.io/topic/39474/solved-android-home-button/5 and https://doc.qt.io/qt-5/qtandroidextras-notification-example.html – aatwo Jul 26 '17 at 09:52
  • thanks ;) i will look into it, maybe i can use the pause signal from the Java Methods and get it to work – GeKo1990 Jul 26 '17 at 10:21
  • i dont think i can overwrite a java method with qtandroidextras, i can only call methods or am i missing something – GeKo1990 Jul 26 '17 at 10:43
  • Mmmm not sure. There were a couple of suggestions in that thread though, including one to monitor the Qt::ApplicationState. Perhaps you could detect changes to that and act accordingly when it changes to Qt::ApplicationSuspended. – aatwo Jul 26 '17 at 10:59
  • yeah i tried that, but its allready too late when ApplicationSuspended happens. This wont work in our case. The app allready is in a Suspended State and when i change it back to active it will just come back from it but thats not what i want :) – GeKo1990 Jul 26 '17 at 11:02
  • Is a fullscreen app a solution: https://stackoverflow.com/questions/26543268/android-making-a-fullscreen-application? – m7913d Jul 26 '17 at 19:31
  • u mean disable the buttons visually? this could help in the case of some devices, but it wont help if the buttons are actually on the device. – GeKo1990 Jul 27 '17 at 10:27

0 Answers0