Pranav Agrawal
Pranav Agrawal

Reputation: 476

How to get onBackPressed event in a service?

Trying to make something similar to facebook chat head. When we click on the chat head it opens up the chat. Now when we press back button it closes the popup of chat. How to capture onBackPressed event in a service?

Upvotes: 0

Views: 1784

Answers (2)

Eric B.
Eric B.

Reputation: 4702

You can use this library here to make floating windows like facebook chat heads. This library's floating windows closes on back button press.

Upvotes: 1

jay shah
jay shah

Reputation: 993

This might work :

make the window or view you show via service as focusable, add a onKeylistener(for e.g. on rootview or other) and listen for KEYCODE_BACK.

Upvotes: 1

Related Questions