I don't know for sure that this is specific to the Galaxy S4 or not, but 2 of 4 people I've talked to with an S4 have reported this problem:
My app intercepts the volume keys being pressed and then sends an intent. Depending on some circumstances that intent either starts an invisible activity in another app or starts a service in another app.
There is a button ("view") in the app that the user can press that calls the exact same sub as in my Activity_Keypress sub. However, apparently that works fine and they only get a crash (Sorry... APP NAME needs to close) if using the volume rocker keys on the phone.
The code does limit how often the intent will be sent, but apparently this crash happens even if only pressing the volume rocker button one single time.
Any ideas? Seems strange!
My app intercepts the volume keys being pressed and then sends an intent. Depending on some circumstances that intent either starts an invisible activity in another app or starts a service in another app.
There is a button ("view") in the app that the user can press that calls the exact same sub as in my Activity_Keypress sub. However, apparently that works fine and they only get a crash (Sorry... APP NAME needs to close) if using the volume rocker keys on the phone.
The code does limit how often the intent will be sent, but apparently this crash happens even if only pressing the volume rocker button one single time.
Any ideas? Seems strange!
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event
If KeyCode = KeyCodes.KEYCODE_MENU Then
If CurrentScreen = "Setup" OR CurrentScreen = "ManualAdd" OR CurrentScreen = "QS" OR CurrentScreen = "FAV2" OR CurrentScreen = "Macro2" Then
Return True ' Don't allow user to press menu key while in these screens
End If
End If
If KeyCode = KeyCodes.KEYCODE_MENU Then ' Use the new custom menus
OpenMenu
Return True
End If
' ============ THIS IS THE PROBLEM AREA =============
' LastVolumeHardKeySentTime is declared as LONG in the Process_Globals section
If KeyCode = KeyCodes.KEYCODE_VOLUME_UP Then
'Log("Vol Up")
If DateTime.Now - LastVolumeHardKeySentTime > 500 Then
LastVolumeHardKeySentTime = DateTime.Now
Common.SendAVCommand ("4")
End If
Return True
End If
If KeyCode = KeyCodes.KEYCODE_VOLUME_DOWN Then
'Log("Vol Down")
If DateTime.Now - LastVolumeHardKeySentTime > 500 Then
LastVolumeHardKeySentTime = DateTime.Now
Common.SendAVCommand ("5")
End If
Return True
End If
' ================================================
If KeyCode = KeyCodes.KEYCODE_BACK Then
CallSubDelayed(Me, "HandleBackKey")
Return True
End If
Return False
End Sub