Bug? Android 4.3 pb with closing the app

imbault

Well-Known Member
Licensed User
Longtime User
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
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
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
 

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
...Seems Resume only (not create) is called when using the Home button.

See http://www.b4x.com/android/wiki/index.php/Tricks_Of_The_Trade#Activity_Create.2C_Pause_and_Resume:

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.
 

jesustarre

Member
Licensed User
Longtime User
Thanks for this Erel!

Make me crazy after 4.3

Erel, I've to pay a upgrade in order to get a fix for this? :(

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
 

tdocs2

Well-Known Member
Licensed User
Longtime User
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!
 

jinxaw

Member
Licensed User
Longtime User
Had the same problem on Nexus 4.
I almost went crazy...

Thanks a lot, Erel. The workaround works perfectly!
 

LeeM

Member
Licensed User
Longtime User
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

Also had this problem on Nexus 7, thanks for the workaround.
Is this workaround ok to use on other devices too ?
 

Ratters

Member
Licensed User
Longtime User
Thanks Erel, I've had issues with the Nexus 10 on 4.3. I'll give it a go.
 

imbault

Well-Known Member
Licensed User
Longtime User
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...

Patrick
 

imbault

Well-Known Member
Licensed User
Longtime User
Here a a sample project, just go in the test menu, then go back...

Patrick
 

Attachments

  • test.zip
    7.4 KB · Views: 463
Top