Android Question KeyPress Event Consuming

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hi,

I'm trying to use volume up button to do an action in an activity but the button is still controlling volume also. Then when user presses the activity detects and does the sub BUT the device volume is changed... is there any way to intercept the volume up keypress event avoiding to increase the sound level when needed? (for real, I'm using Activity_KeyUp and Activity_KeyDown , but I think that the event consuming technique will be the same...)

Thanks!
 

Marcos Alves

Well-Known Member
Licensed User
Longtime User
You should add a Return True in the routine to consume the event?
Hi @klaus , thanks! But I noticed another problem: I need to turn off the screen when activating the function and when doing that the activity automatically pauses. Then, there is no event anymore. So, the problem grows: is there any way to intercept keypress (down/up) inside a service OR to avoid the activity pause when turning off the screen?
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Sorry, I don't know.
We are implementing a radio/ptt function. Then, the keypress function when the screen is locked is a great function because allows the user to lock the screen and use device phone (instead of speakerphone) if privacy is needed. Use an on screen button isn't really good because the user could accidentally touch and execute mistaken commands. Of course that U could use a panel over the activity to block, with other physical button to unlock (or a specific sequence of touches). But this is not really an elegant solution.
 
Upvote 0
Top