在开发软件的过程中,遇到过这样一种情况,就是没有create bundle,但是当你使用intent.putExtra之后,在另一个被call的activity中,会有bundle被传递过去,
原因就是因为intent.putExtra时,系统会检测有没有bundle,如果没有,则新建一个。所以下面这两个语句的等效的:
1
Intent intent = new Intent(this,xxx.class);
intent.putExtra("test", true);
startActivity(intent);
2
Intent intent = new Intent(this,xxx.class);
Bundle bundle = new Bundle();
bundle.putBoolean("test", true);
intent.putExtras(bundle);
startActivity(intent);