[Interest] Qt 5.6.1 widget app terminates if do not accept Android back key ?

Eddie Sutton eddie.of.the.spam at gmail.com
Fri Oct 7 21:19:26 CEST 2016


> On Oct 7, 2016, at 2:15 PM, Gianluca <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.

-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/3bf614ac/attachment.html>


More information about the Interest mailing list