Hi,
I don't know if it's a bug, but my nexus 4 had just upgraded to android4.3, I have a weird problem since this upgrade:
If I press 2 times the Keycode_back then select No, the second time I've got a closing of my app, the log says:
Fatal signal 11 (SIGSEGV) at 0x002e0064 (code=1), thread 13690 (pim_gss_ics.com)
can someone else confirm this isssue?
Thks.
Patrick
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
Dim Answ As Int
Dim txt As String
Select KeyCode
Case KeyCodes.KEYCODE_BACK
txt = "Please confirm to Quit"
Answ = Msgbox2(txt, "A T T E N T I O N", "Yes", "", "No", Null)
If Answ = DialogResponse.NEGATIVE OR Answ = DialogResponse.CANCEL Then
Return True
Else
Return False
End If
End Select
End Sub
I see it too. This will be fixed in the next update. The workaround for this issue is to use CallSubDelayed:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
Select KeyCode
Case KeyCodes.KEYCODE_BACK
CallSubDelayed(Me, "HandleBackKey")
Return True
End Select
Return False
End Sub
Sub HandleBackKey
Dim Answ As Int
Dim txt As String
txt = "Please confirm to Quit"
Answ = Msgbox2(txt, "A T T E N T I O N", "Yes", "", "No", Null)
If Answ = DialogResponse.POSITIVE Then
Activity.Finish
End If
End Sub
Just to be sure, this workaround will work, but with a different behaviour?
Pressing the back key causes the Activity to become paused, I though Activity.Finish will remove the activity from memory as well?
I see. I never realized that.
I thought pressing back just removes the activity from the stack, but if it is invoked again, only resume is called.
EDIT: Seems Resume only (not create) is called when using the Home button.
Two events can cause a Pause-Resume without rerunning Create:
The user presses Home and resumes the app before the device's operating system ("OS") removes it from memory to make room for other apps.
The device is put into its Sleep mode while in the app. When brought out of Sleep mode (and past the device's security screen, if any), the device resumes the app from the same point it was at. If the user has pressed Home before entering Sleep, the previous event occurs. Also, note the exception further down where the device is rotated while coming out of Sleep mode.
A phone call (or the user switching an app through one of the several ways to switch apps) will cause the activity to be paused without being destroyed.
I see it too. This will be fixed in the next update. The workaround for this issue is to use CallSubDelayed:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
Select KeyCode
Case KeyCodes.KEYCODE_BACK
CallSubDelayed(Me, "HandleBackKey")
Return True
End Select
Return False
End Sub
Sub HandleBackKey
Dim Answ As Int
Dim txt As String
txt = "Please confirm to Quit"
Answ = Msgbox2(txt, "A T T E N T I O N", "Yes", "", "No", Null)
If Answ = DialogResponse.POSITIVE Then
Activity.Finish
End If
End Sub
I had a similar problem with Nexus 7 - Android 4.3.
Thank you, Erel. I suspected it had to be a timing problem and had experimented for a couple of days with a number of workarounds, but could not pinpoint it. Simply brilliant.
PS: desolatesoul responded to my thread in 6 minutes! You got to love this community!
I see it too. This will be fixed in the next update. The workaround for this issue is to use CallSubDelayed:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
Select KeyCode
Case KeyCodes.KEYCODE_BACK
CallSubDelayed(Me, "HandleBackKey")
Return True
End Select
Return False
End Sub
Sub HandleBackKey
Dim Answ As Int
Dim txt As String
txt = "Please confirm to Quit"
Answ = Msgbox2(txt, "A T T E N T I O N", "Yes", "", "No", Null)
If Answ = DialogResponse.POSITIVE Then
Activity.Finish
End If
End Sub
Erel, still problems with android 4.3 and back key in activities involving mgsbox like saving datas, etc...
Any workaround, cause your first one is OK in main activity but doesn't work in sub activity...