views:

40

answers:

1

Is there anyway to intercept that a hard key was pressed by using a service in order to launch an activity?

In other words : Is it possible to handle the KeyEvents in the Service?

+1  A: 

There is no general way to listen for the key events of the hardware keys from anything besides the currently active application.

Only the CAMERA button event can be detected, via its broadcast Intent.

The ACTION_CAMERA_BUTTON is broadcast when the CAMERA button is pressed and is not intercepted by the foreground activity: developer.android.com/reference/android/content/…

This means you can only detect the press if the application in the foreground is not handling the key press.

CommonsWare
No link, no hint no further information? You can do better ;)
Janusz
@Janusz: My apologies for not meeting your standards. The `ACTION_CAMERA_BUTTON` is broadcast when the CAMERA button is pressed and is not intercepted by the foreground activity: http://developer.android.com/reference/android/content/Intent.html#ACTION_CAMERA_BUTTON
CommonsWare