获取Activity栈顶以及它所属的App Process is Deprecated

@Deprecated
public static final String GET_TASKS = "android.permission.GET_TASKS";
@Deprecated
public List<RunningTaskInfo> getRunningTasks(int maxNum)
throws SecurityException {
try {
return ActivityManagerNative.getDefault().getTasks(maxNum, 0);
} catch (RemoteException e) {
// System dead, we will be dead too soon!
return null;
}
}

@deprecated As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method
Android L开始,Google开始对getRunningTasks接口进行限制使用。
应用要使用该接口必须声明权限android.permission.REAL_GET_TASKS
而这个权限是不对三方应用开放的。(在Manifest里申请了也没有作用)
系统应用(有系统签名)可以调用该权限。
Google这样做的原因还是出于安全考虑,对普通应用开发该接口可能会造成用户的隐私泄露。
获取Activity栈顶以及它所属的App Process is Deprecated

    原文作者:cd2016
    原文地址: https://www.jianshu.com/p/dec440095573
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞