从一个意图转发到另一个意图

时间:2012-12-03 15:04:31

标签: android android-intent bundle

有没有办法将意图包从一个意图传递到另一个意图而不必提取包并单独处理每个意图?

示例:

intent2.setExtras(intent2.getExtras());

2 个答案:

答案 0 :(得分:2)

为什么不呢?鉴于存在3个活动:ActivityA,ActivityB和ActivityC ...

活动A

Intent intentA = new Intent(this,ActivityB.class);
intentA.putExtras(new Bundle());

活动B

Intent intentB = new Intent(this,ActivityC.class);
intentB.putExtras(getIntent());

活动C

Intent intentFromA = getIntent();
// Consume and process the Bundle here.

答案 1 :(得分:2)

有专门的功能

Intent.putExtras(Bundle extras)

希望这会有所帮助 哔叽