2

How to detect the recent buttons click in android. If I use the, onWindowFocusChanged, It's calling if any new activity started. If I try to use ActivityManager.getRunningTasks and check the top activity's package name is the applications package name only. So, is there any alternative ways to handle the recent buttons click?

Recents screen button

In this picture, there are 3 buttons. I want to listen for the right most button (recents screen button).

I have tried onWindowFocusChanged(boolean hasFocus) in the activity, the hasFocus value is false if the app goes to background by recents button click. But, it is getting false if any of the new activity (within the app) has started. Want to over come that issue. Is there any way to achieve this?

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141

1 Answers1

0

You can use isFinishing() method in onPause() to find out the activity is finished or not.

Strange
  • 59
  • 1
  • 8
  • Yes, buddy! Have checked that. It's also, returns false all the time. As, I mentioned if any new activity started, that time also that method returning false. So, no use. – Vignesh Thillai May 05 '16 at 07:12