ActivityManager topActivity 不适用于棒棒糖
ActivityManager topActivity not working with lollipop
我有一个应用程序在应用程序之间一段时间不活动后使用 topActivity
调用超时,它在 android 4.x 上运行良好,但自从更新到 5.x 这已停止工作。
完整调用是
ActivityManager am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
String packageName = am.getRunningTasks(1).get(0).topActivity.getPackageName();
有没有人以前遇到过这种情况或有解决方案?没有错误,只是没有返回预期的内容。
注意:这不是商业应用程序,这是非常有限的托管分发。
引用 the documentation for getRunningTasks()
:
This method was deprecated in API level 21.
As of LOLLIPOP, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak person information to the caller. For backwards compatibility, it will still return a small subset of its data: at least the caller's own tasks, and possibly some other tasks such as home that are known to not be sensitive.
我有一个应用程序在应用程序之间一段时间不活动后使用 topActivity
调用超时,它在 android 4.x 上运行良好,但自从更新到 5.x 这已停止工作。
完整调用是
ActivityManager am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
String packageName = am.getRunningTasks(1).get(0).topActivity.getPackageName();
有没有人以前遇到过这种情况或有解决方案?没有错误,只是没有返回预期的内容。
注意:这不是商业应用程序,这是非常有限的托管分发。
引用 the documentation for getRunningTasks()
:
This method was deprecated in API level 21.
As of LOLLIPOP, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak person information to the caller. For backwards compatibility, it will still return a small subset of its data: at least the caller's own tasks, and possibly some other tasks such as home that are known to not be sensitive.