Is it possible to create an Android Service that listens for hardware key presses?

前端 未结 4 1406
小鲜肉
小鲜肉 2020-11-29 00:57

I\'d like to run an Android background service that will act as a keylistener from the home screen or when the phone is asleep. Is this possible?

From semi-related

4条回答
  •  青春惊慌失措
    2020-11-29 01:28

    While it is not possible to listen for hardware key presses directly in a service, you can sometimes listen for the effects of those key presses. For example, this answer describes how to infer volume key presses from changes in media volume.

提交回复
热议问题