ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks(1).get(0).topActivity;
This method cannot be used above Android 5.0, and all returned are desktop packages.
How to judge after 5.0? I hope the great god can give me some advice!
Are you doing launcher?Detects whether an Activity is at the top of the stack of the current Task.