Erel could you please help me
When i Press the volume Button my app Chrashes with the Posted error
my code is:
If KeyCode = KeyCodes.KEYCODE_VOLUME_DOWN Then
Dim PhoneVol As Phone
Dim temp As Int
temp = PhoneVol .GetVolume(PhoneVol .VOLUME_MUSIC)
If temp > 0 Then
temp = temp - 1
PhoneVol .SetVolume(PhoneVol .VOLUME_MUSIC, temp, True)
End If
End If
If KeyCode = KeyCodes.KEYCODE_VOLUME_UP Then
temp = PhoneVol .GetVolume(PhoneVol .VOLUME_MUSIC)
If temp < PhoneVol .GetMaxVolume(PhoneVol .VOLUME_MUSIC) Then
temp = temp + 1
PhoneVol .SetVolume(PhoneVol .VOLUME_MUSIC, temp, True)
End If
End If
My other Problem is that i Use the Back key not only to close my application
For example i Set some Views/controls to Visible false when i press the backkey (when the views are visible true --> back key --> views visible false)
Note that a DoEvents call will also trigger this issue.
I've tested it on a device without a menu button so I wasn't able to catch the menu key (remember that many devices don't have a menu button). I've tried it with this code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
If KeyCode = KeyCodes.KEYCODE_VOLUME_DOWN Then
StartActivity(a1)
End If
End Sub
It didn't raise any error.
Please try it and change it to the menu button and see whether it works or not.