Android Question Problem with KeyCodes.KEYCODE_VOLUME_UP etc...

DouglasNYoung

Active Member
Licensed User
Longtime User
Hi,
I'm tying to intercept Volume UP and Down with this code (pretty well lifted straight off the forum)
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
'Return True to consume the event
   If KeyCode = KeyCodes.KEYCODE_VOLUME_UP Then
     Log("Up")
     Return True
   End If
   If ( KeyCode = KeyCodes.KEYCODE_VOLUME_DOWN ) Then
     Log("Down")
     Return True
   End If
End Sub

but when I try to compile I get
Parsing code. Error
Error parsing program.
Error description: keycode is not a valid identifier.
Occurred on line: 51
If KeyCode = KeyCodes.KEYCODE_VOLUME_UP Then
OR (depending on some factor that I don't understand?)
Parsing code. Error
Error parsing program.
Error description: Input string was not in a correct format.
Occurred on line: 51
If KeyCode = KeyCodes.KEYCODE_VOLUME_UP Then

I can't see anything wrong, but cannot get it to work!
No doubt its something simple, but not obvious (to me) - ANY IDEAS?

Thanks in advance Douglas
 

DouglasNYoung

Active Member
Licensed User
Longtime User
NJDude,
If I comment out the entire
Sub Activity_KeyPress

It compiles and runs OK.


Whils I can upload the project, I'd have to blank out database passwords and some http addresses, which means the project wouldn't run correctly, but might compile!

Douglas
 
Upvote 0

DouglasNYoung

Active Member
Licensed User
Longtime User
NJDude,
Thanks, I typed it out again and it works - I'm guessing there must be some hidden characters in the cut and paste version!

eps, FYI: Line 51 was the 'If KeyCode = KeyCodes.KEYCODE_VOLUME_UP Then'

Thanks,
Douglas
 
Upvote 0
Top