[Interest] Qt 5.6.1 widget app terminates if do not accept Android back key ?
Gianluca
gmaxera at gmail.com
Fri Oct 7 21:26:15 CEST 2016
> Il giorno 07 ott 2016, alle ore 20:19, Eddie Sutton <eddie.of.the.spam at gmail.com> ha scritto:
>
>
>> On Oct 7, 2016, at 2:15 PM, Gianluca <gmaxera at gmail.com <mailto:gmaxera at gmail.com>> wrote:
>>
>>>
>>> Il giorno 07 ott 2016, alle ore 20:09, Eddie Sutton <eddie.of.the.spam at gmail.com <mailto:eddie.of.the.spam at gmail.com>> ha scritto:
>>>
>>> Thank you for your reply Jason.
>>>
>>>> On Oct 7, 2016, at 1:01 PM, Jason H <jhihn at gmx.com <mailto:jhihn at gmx.com>> wrote:
>>>>
>>>> It seems like the activity catches it and removes itself from the stack.
>>>> Is it crashing? If so paste the exception.
>>>
>>> I think maybe you are correct.
>>>
>>> I see no exceptions in adb. Instead it appeared the app was closed deliberately.
>>>
>>> Perhaps the problem is that I do not understand the Android back button. Does an Android user expect the back button to close an app?
>>>
>>>
>>> D/TSR (25898): ../source/source/mainwindow.cpp:812 (virtual void tcmw::MainWindow::closeEvent(QCloseEvent*)): ************************* C L O S E ******************
>>>
>>> I/ActivityManager( 563): Process com.ditchwitch.tsr (pid 25898) (adj 9) has died.
>>> I/WindowState( 563): WIN DEATH: Window{42c61a48 u0 com.ditchwitch.tsr/com.ditchwitch.tsr.tsractivity.TsrActivity}
>>> W/WindowManager( 563): Force-removing child win Window{42caa3f8 u0 SurfaceView} from container Window{42c61a48 u0 com.ditchwitch.tsr/com.ditchwitch.tsr.tsractivity.TsrActivity}
>>>
>>>
>>>
>>> I expected Android button to retain my app state, suspend app to background, then restore suspended state when reactivated.
>>
>> Default behavior of Android on back button is to terminate the application.
>> If you don’t want this behavior you have to capture the back button and handle.
>> This is not Qt thing … it happens also if you are programming in Java.
>>
>> http://www.androiduipatterns.com/2011/03/back-button-behavior.html <http://www.androiduipatterns.com/2011/03/back-button-behavior.html>
>
> So most Android users will be irritated if I intercept the back button and do not let the app close??
>
> I thought the Android back button was supposed to back-track through the apps the user had opened before the current app.
:-D one thing is what the Android system does by default … another is what the users except :-D
So, what users except are:
- if the app is its very first screen, pressing back button will exit from the app and go to the home screen but when the user will open the app again is expecting to see exactly the same state as before like the app was in the background. So you should save the status and restart the app has it should never been stopped.
- if the app is into an internal page, pressing back button will just navigate backward into the history (or app views structure) without exiting from the app.
But unfortunately this is up to the programmers to do into the Android world :-(
>
> -Ed
>
>
>>
>>
>>>
>>>
>>> -Ed
>>>
>>>
>>>> >Has anyone seen this?
>>>>
>>>> I cannot find any useful clues in adb.
>>>>
>>>> The app terminates unless I add a keyReleaseEvent to accept the Key_Back.
>>>>
>>>>
>>>> #if defined(Q_OS_ANDROID)
>>>> ///
>>>> /// Android back button kills TSR ?
>>>> ///
>>>> /// Adding a keyReleaseEvent that accepts the event prevents the crash.
>>>> /// I do not understand reason why.
>>>> ///
>>>> /// Ignoring the Android back button will annoy users but is better than crashing.
>>>> ///
>>>> void MainWindow::keyReleaseEvent(QKeyEvent *event)
>>>> {
>>>> if( Qt::Key_Back == event->key())
>>>> {
>>>> qDebug("Android Back button");
>>>> event->setAccepted(true);
>>>> }
>>>> }
>>>> #endif
>>>>
>>>> Thanks in advance,
>>>>
>>>> -Ed
>>>>
>>>> _______________________________________________ Interest mailing list Interest at qt-project.org <mailto:Interest at qt-project.org> http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>
>>> _______________________________________________
>>> Interest mailing list
>>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>>> http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161007/e0800071/attachment.html>
More information about the Interest
mailing list