Android Question Pressing a Key in Code

mjtaryan

Active Member
Licensed User
Longtime User
Lets say I have a "Home" button on the screen and I want it to do precisely what the real button does. How then, do I programatically press the actual Home key? Activity_KeyPress captures or discards keypresses depending on the returned value, which is not what I'm looking for. What I want to do is to press one of the keys/buttons such as Home, Menu, Back, Volume Up, Volume Down from within the code so that a physical press of the actual key is not needed. I guess another way of asking my question is, "What are the events for these buttons and how do I trigger/call them from code?" Thanks.
 

mjtaryan

Active Member
Licensed User
Longtime User
It is relateds not possible to "simulate" a key press in Android.

Home - Progmatically go to Home Screen
Back - Activity.Finish
Menu - Activity.OpenMenu
Volume - Change the volume with the Phone library.

Thanks Erel. That will help some. My questin is related to VR and of the questions I mentioned having in your VR tutorial. More questions to come in new threads.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…