Bundle是key-value存储。
Bundle bundle=new Bundle();
bundle.putString("key", "value");
Bundle bundle=new Bundle();
bundle.putString("key", "value");
Intent a= new Intent(this,TargetActivity.class);
a.putExtras(bundle);
如果不是在Activity类方法中,而是在其他类中,可以使用下面的方式声明Intent。
public class ActivityInstance extends Activity{ protected void onCreate(Bundle savedInstanceState) {}
private class RegisterOnclick implements View.OnClickListener {
public void onClick(View v) {
Intent a= new Intent(ActivityInstance.this,TargetActivity.class);
}}
}
这里涉及到如何获取Context.