0

I need to detect HomeButton event in Service. Not in Activity.

I am making an app which will make overlay on any other App. Like additional menu which is always on top of the screen. In some specific events I need to override pressing home button, menu button, back button, volume button also power button.

I believe that this must be done in Service, since all other Apps must run normal. So the events must be handled in Service not in Activity.

It is possible: http://www.kidscrape.com

5er
  • 2,506
  • 7
  • 32
  • 49

1 Answers1

0

You might want to find a way how to communicate from the Activity to the Service (and conversely). The easiest would be to use EventBus, either on of these two:

  1. http://square.github.io/otto/
  2. https://github.com/greenrobot/EventBus

So ultimately you just fire an event from Activity#onBackPressed() and catch it in the Service.

Eugene
  • 59,186
  • 91
  • 226
  • 333