Android 如何获取最顶端的Top Activity, 见如下代码:
public static class TopActivityInfo {
public String packageName = "";
public String topActivityName = "";
}private TopActivityInfo getTopActivityInfo() {
ActivityManager manager = ((ActivityManager)GlobalConfig.getContext().getSystemService(Context.ACTIVITY_SERVICE));
TopActivityInfo info = new TopActivityInfo();
if (Build.VERSION.SDK_INT >= 21) {
List pis = manager.getRunningAppProcesses();
ActivityManager.RunningAppProcessInfo topAppProcess = pis.get(0);
if (topAppProcess != null && topAppProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
info.packageName = topAppProcess.processName;
info.topActivityName = "";
}
} else {
<