Hi in my code I'm trying to catch the home Button click in android i'm using this code for capture the home button click
public boolean isApplicationSentToBackgroundAbove(final Context context) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1);
if (!tasks.isEmpty()) {
ComponentName topActivity = tasks.get(0).topActivity;
if (!topActivity.getPackageName().equals(context.getPackageName())) {
return true;
}
}
return false;
}
on onPause() function i'm calling this
if (isApplicationSentToBackground(this)){
Log.i("Activitymain","Home is press");
}
This function work fine below 5 OS. (Sony 4.4.2 also does not work) rest of the OS is working
how to solve this issue