I have an app that is using the topActivity
call to timeout after a period of inactivity between apps, which worked fine on android 4.x but since the update to 5.x this has stopped working.
The full call is
ActivityManager am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
String packageName = am.getRunningTasks(1).get(0).topActivity.getPackageName();
Has anyone experienced this before or have a solution? There are no errors it is just not returning what is expected.
Note: This is not for a commercial app, this is for a very limited, managed distribution.
Quoting 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.