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?
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?