In facebook chatheads, that are part of the facebook messenger app, I noticed the following behavior: As far as I can see, the chat head itself and the opened chat screen ar
This is my way. It work fine. Put it in onReceive() function.
if (intent.getAction().equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
{
String reason = intent.getStringExtra(SYSTEM_REASON);
//Toast.makeText(context,"ACTION_CLOSE_SYSTEM_DIALOGS : Reason : " + reason ,Toast.LENGTH_LONG).show();
// Detect home screen key press or "recent app" key pressed when screen is in unlocked state
if (reason != null)
{
if (reason.equals(SYSTEM_HOME_KEY))
{
// For Home press
}
else if (reason.equals(SYSTEM_RECENT_APPS))
{
// For long press
}
}
}