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

java-Android中ActivityManager.getRecentTasks()的替代方法?,第1张

概述目前,我发现通过android框架检索最近启动的应用程序历史的唯一方法是使用ActivityManager.getRecentTasks().自从Android文档网站UI进行大修以来,我现在看到对此方法添加了一条注释:Note:thismethodisonlyintendedfordebuggingandpresentingtaskmanagementuserinte

目前,我发现通过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.

有哪些更安全的替代方法可以做到这一点?

解决方法:

棒棒糖不推荐使用该方法;但是,有一个新的API可让您查看应用使用情况.

UsageStatsManager提供了一些有用的方法来查看一段时间间隔内的活动.
希望这足以满足您的需求!

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

总结

以上是内存溢出为你收集整理的java-Android中ActivityManager.getRecentTasks()的替代方法?全部内容,希望文章能够帮你解决java-Android中ActivityManager.getRecentTasks()的替代方法?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1075353.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存