问题描述
我挣扎,在我的应用程序的问题。我想提供一种方法来列出previous拉开活动的历史。
我觉得有两种可能的解决方案,但我不知道要找到一个稳定的方式来实现其中任何一个。
- 在某种方式使用功能的SDK。我尝试使用getPackageManager()和getActivityManager(),但我找不到任何合适的解决方案
- 在实现自己的历史,但后来我不得不重写startActivity,我真的不希望走这条道路作为一项活动可以在其他多种方式启动。
那么,有没有办法做到这一点使用功能的SDK?
非常感谢。
编辑:
我有另外一个想法,这是一个有点不同。有没有可能听开始/结束的活动与某种接收到特定的应用程序(我的)事件和跟踪栈的历史?
没有,不好意思。
您可以使用 registerActivityLifecycleCallbacks()
在应用程序
,如果你只打算支持API级别14或更高(又名,安卓4.0 +)。
I'm struggling with an issue in my app. I'd like to provide a way to list the history of the previous opened activities.
I think there are two potential solutions but I'm not sure to find a stable way to achieve any of them.
- Somehow use a function from the SDK. I tried using getPackageManager() and getActivityManager() but I can't find any suitable solution
- Implement my own history but then I'll have to override startActivity and I don't really want to go down that way as an activity can be started in other multiple ways.
So is there a way to do that using a function from the SDK?
Many thanks.
EDIT:
I've got another idea, it's a bit different. Would it be possible to listen to "start/finish activity" events with some kind of receiver to a specific app (mine) and keep track of the stack history?
No, sorry.
You can use registerActivityLifecycleCallbacks()
on Application
, if you are only going to support API Level 14 and higher (a.k.a., Android 4.0+).
这篇关于如何获得活动历史堆栈的名单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!