Sub Activity_Create(FirstTime As Boolean)
re.Target = Activity
re.SetOnKeyListener("ActivityOnKey")
re.RunMethod2("setFocusable", "True", "java.lang.boolean")
re.RunMethod2("setFocusableInTouchMode", "True", "java.lang.boolean")
Activity.RequestFocus
End Sub
Private Sub ActivityOnKey(vTag As Object, keyCode As Int, KeyEvent As Object) As Boolean
re.Target = KeyEvent
Dim Action As Int = re.RunMethod("getAction")
Select Action
Case Activity.ACTION_DOWN
Select keyCode
Case KeyCodes.KEYCODE_MEDIA_PREVIOUS
'MsgboxAsync(keyCode,"MEDIA PREVIOUS DOWN")
Return(True) 'to cancel the event
Case KeyCodes.KEYCODE_MEDIA_NEXT
'MsgboxAsync(keyCode,"MEDIA NEXT DOWN")
Return(True) 'to cancel the event
Case KeyCodes.KEYCODE_MEDIA_PLAY_PAUSE
'MsgboxAsync(keyCode,"MEDIA PLAY / PAUSE DOWN")
Return(True) 'to cancel the event
Case KeyCodes.KEYCODE_VOLUME_UP
'MsgboxAsync(keyCode,"VOLUME UP down")
Return(True) 'to cancel the event
Case KeyCodes.KEYCODE_VOLUME_DOWN
'MsgboxAsync(keyCode,"VOLUME DOWN down")
Return(True) 'to cancel the event
End Select
Case Activity.ACTION_UP
ToastMessageShow(keyCode & KeyEvent,True)
Select keyCode
Case KeyCodes.KEYCODE_MEDIA_PREVIOUS
MsgboxAsync(keyCode,"MEDIA PREVIOUS")
Return(True) 'to cancel the event
Case KeyCodes.KEYCODE_MEDIA_NEXT
MsgboxAsync(keyCode,"MEDIA NEXT")
Return(True) 'to cancel the event
Case 126
'Case KeyCodes.KEYCODE_MEDIA_PLAY_PAUSE 'DOESN'T WORK!
MsgboxAsync(keyCode,"MEDIA PLAY / PAUSE")
Return(True) 'to cancel the event
Case KeyCodes.KEYCODE_VOLUME_UP
MsgboxAsync(keyCode,"VOLUME UP up")
Return(True) 'to cancel the event
Case KeyCodes.KEYCODE_VOLUME_DOWN
MsgboxAsync(keyCode,"VOLUME DOWN up")
Return(True) 'to cancel the event
End Select
End Select
Return False
End Sub