gpt4 book ai didi

java - Android 中 ActivityManager.getRecentTasks() 的替代方案?

转载 作者:太空狗 更新时间:2023-10-29 12:51:22 28 4
gpt4 key购买 nike

目前,我发现通过 android 框架检索最近启动的应用程序历史记录的唯一方法是使用 ActivityManager.getRecentTasks()

自从 Android 文档站点 UI 大修后,我现在看到已将注释添加到此方法中:

Note: this method is only intended for debugging and presenting task management user interfaces. This should never be used for core logic in an application, such as deciding between different behaviors based on the information found here. Such uses are not supported, and will likely break in the future. For example, if multiple applications can be actively running at the same time, assumptions made about the meaning of the data here for purposes of control flow will be incorrect.

实现此目的更安全的替代方法是什么?

最佳答案

Lollipop 弃用了该方法;但是,有一个新的 API 允许您查看应用程序使用情况。

UsageStatsManager 有一些有用的方法来查看时间间隔之间的 Activity 。希望这足以满足您的需求!

https://developer.android.com/reference/android/app/usage/package-summary.html

关于java - Android 中 ActivityManager.getRecentTasks() 的替代方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11979830/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com