I want to be able to capture key events inside a service I am writing. I can do this inside an activity without problems, but all my attemps to get this working in a service have failed. The key I wanted to capture (globally) is the BACK button, but if this is not possible any (hardware) button a HTC Desire offers would be OK.
A:
A Service has no UI so it doesn't receive any input from the User.
Now if you had an activity that managed the service then you could make the service do something special when the back key was pressed while in your activity.
BrennaSoft
2010-07-12 16:00:47
+1
A:
Yes, Android's activities only receives KeyEvents
when they have focus.
The only way to "globally" capture a back button press is creating an InputMethod so you can intercept hard key events.
Remember that using your own InputMethod
will not allow you to use custom keyboards like Swiftkey for instance.
Did you try to reach HTC on this issue?
Macarse
2010-07-12 17:01:39
It's not my device (I have an Samsung Galaxy I9000 -- which has it's own problems ;) ) but that one of a friend of mine. He searched some forums, found some people having the same problem but no solution so far (I don't know if he contacted HTC).But after Android being open so that we should be able to fix the problems we encounter (so I thought) the idea was to do just that. ;)
2010-07-12 17:56:05