article

Amelia@Amazon avatar image
Amelia@Amazon Posted · · Ross@Amazon edited ·

ActivityManager.AppTask has been Deprecated to Improve Security   

Summary

As of Android 5(API level 21), ActivityManager#getRunningTasks (https://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks%28int%29) and ActivityManager#getRecentTasks (https://developer.android.com/reference/android/app/ActivityManager.html#getRecentTasks%28int,%20int%29) methods of ActivityManager (https://developer.android.com/reference/android/app/ActivityManager.html) class are deprecated. Prior to Android 5, these methods used to return all tasks that included outside of the caller's app, which Google decided to deprecate to improve user privacy. For backwards compatibility, these methods still return small subset of tasks which includes caller's own tasks and non-sensitive tasks such as home task.

Resolution

Unfortunately existing task switcher genre apps that use these methods to show background running apps and switch the app to foreground have no alternate way to accomplish this from Android 5. If the app uses these methods to retrieve it's own tasks, you should use ActivityManager#getAppTasks (https://developer.android.com/reference/android/app/ActivityManager.html#getAppTasks%28%29)instead to retrieve that information. Also you can use ActivityManager#getRunningAppProcesses (http://developer.android.com/reference/android/app/ActivityManager.html#getRunningAppProcesses%28%29) to retrieve application processes that are running on the device.

Comment from Google can be seen here: https://code.google.com/p/android-developer-preview/issues/detail?id=29#c50

Keywords: Deprecated Methods, AppTask, Task Switching

[KB_0038]

androidlollipop
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Article

Contributors

rossbria contributed to this article brizzlebrazzle contributed to this article