Cannot get foreground activity name in Android Lollipop 5.0 only

前端 未结 7 2040
旧巷少年郎
旧巷少年郎 2020-12-02 16:02

I use the following code to get the activity name of the foreground app in the variable foregroundTaskPackageName. It works on all OS versions between 4.1 t

7条回答
  •  失恋的感觉
    2020-12-02 16:41

    As per getRunningTasks() docs:

    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.

提交回复
热议问题