04-04-2009 04:57 AM
Is there any way to get the key events if my application is running on the background.
I am only able to get the events of cancel, menu and back button events.
I want to get the events of the characters entered on the keyboard.
05-11-2009 11:36 AM
Can u plz tell me how u got the events of cancel, menu and back button events. Am trying to get key events from a background application, but i can see thats s not possible. Any help would be appreciated.
05-12-2009 01:57 AM
You can get the keyevents for cancel, menu button , back by implementing the KeyListener interface.
Add the keyListener to your listening class and implement the methods of keylistener interface.
I have removed the keylistener from my current code. So dont rememeber exactly which method was getting invoked when a key event occurs on cancel and other 3 keys.
The little i remember it was the keyChar method of keylistener which was getiing invoked.
Try sop in keyChar method it will return you different keyCode for 4 keys.
05-12-2009 04:41 AM
I think we might have some confusion here. As RexDoug said, to get key Events, you have to be in the Foreground. The OP is saying that the application is running in the Background. The KeyListener Interface works on listening of key strokes against UI components - if the UI Component is not displayed (which typically it won't be if the Application is the Background), then that interface will not help.
So let us summarize the situation.
If the Application is not displaying something on the Display(say a Screen, PopupScreen or Dialog), then it will not receive Key Events.
So is there any UI Component that is owned by the Background Application being displayed on the Device at the time the Background Application wants to receive Key Events? If the answer to this question is no, then the Application can not receive Key Events
05-12-2009 05:16 AM
Hi Peter I only tried it out on the Simulator. My Application was a UIApplication which was in the background.
I added the keylistener to it and I was getting the sop's in keyChar method for only the cancel, call, menu and back key.
May be it might not work in real device but i was only able to catch the events for the above 4 keys in keyChar method
05-12-2009 05:34 AM
Does your application only runs in background? Or does it has any gui components associated with it?
If its background application, then you want to extend Application instead of UiApplication.
05-12-2009 06:37 AM
@ safycoolI added the keylistener to it and I was getting the sop's in keyChar method for only the cancel, call, menu and back key.
While your application is running as background after calling requestBackground(), does your keyChar method able to get those four keys still then?
05-12-2009 07:00 AM