调用服务的活动或接收者的名称
我有一个从接收者或活动调用的意图服务。我想知道触发服务的接收者或活动的名称。我不想使用任何额外的内容或标志来传递给服务。
有没有办法在代码运行时查看活动堆栈?
I have a Intent service which is called from either a receiver or an activity. I would like to know the name of the receiver or activity that triggers the service. I don't want to use any extras or flags to pass to the service.
Is there a way to see the activity stack while the code is on the run?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,没有办法检测意图的发送者。
As far as I know there is no way to detect sender of the Intent.
您可以使用 ActivityManager.RunningTaskInfo。虽然它没有提供太多 API,但可能足以满足您的要求。伪代码:
它使您能够检索特定任务(又称后堆栈)的顶部和根活动,请注意,您需要设置 persimmon GET_TASKS。
You can use ActivityManager.RunningTaskInfo. Though it doesn't provide much API, it is probably sufficient for your requirements. Pseudocode:
It gives you ability to retrieve the top and root activities of a specific task (AKA. back stack), Note that you need set persimmon GET_TASKS in AndroidManifest.xml.