Forward bundle from one intent to another

喜欢而已 提交于 2019-12-11 06:13:21

问题


Is there a way to pass an intent bundle from one intent to another without having to extract the bundle and handle each extra individually?

Example:

intent2.setExtras(intent2.getExtras());

回答1:


There is a dedicated function

Intent.putExtras(Bundle extras)

Hope this helps Serge




回答2:


Why not? Given that there exist 3 Activities: ActivityA, ActivityB, and ActivityC...

Activity A

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

Activity B

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

Activity C

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


来源:https://stackoverflow.com/questions/13685934/forward-bundle-from-one-intent-to-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!