如何在Android中找到Intent源? [英] How to find Intent source in Android?

查看:37
本文介绍了如何在Android中找到Intent源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
Android:如何获取 Intent 的发送者?

android 中有没有办法找到触发 INTENT 的源活动(在目标活动中)?

场景是我有两个活动 A 和 B.两者都触发了调用活动 C 的意图.活动 C 根据其来源显示额外信息.例如.如果呼叫来自 A,则 C 仅显示 2 个文本视图,而在 B 触发意图的情况下,活动 C 显示 3 个文本视图(基本上更多信息基于呼叫者).

The scenario is I have two activities A and B. Both fire an intent to call activity C. Activity C displays extra information based on its source. Eg. If call comes from A then C displays only 2 textviews whereas in the case of intent fired by B the activity C displays 3 textviews (basically more information based on who is the caller).

要确定这一点,我需要知道是谁触发了调用 C 的意图.我该怎么做?

To establish this I need to know who fired the intent calling C. How do I do this?

推荐答案

一个更好的方法是使用 Intent extras 将参数传递给接收者.

A better way to do this would be to use Intent extras to pass parameters to the receiver.

这篇关于如何在Android中找到Intent源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆