im trying to send two bundles at once from one activity to another and im having no luck.. i can send a bundle ok but when i try two send two i get a null pointer. heres my code:
Activity A,
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TextView name = (TextView) v.findViewById(R.id.label2);
TextView number1 = (TextView) v.findViewById(R.id.label);
Intent i = new Intent(this, options_Page.class);
// Bundle bundle2 = new Bundle();
Bundle bundle1 = new Bundle();
bundle1.putString("title", number1.getText().toString());
// bundle2.putString("title2", name.getText().toString());
i.putExtras(bundle1);
// i.putExtras(bundle2);
startActivity(i);
Activity B,
Bundle bundle1 = this.getIntent().getExtras();
// Bundle bundle2 = this.getIntent().getExtras();
String title = bundle1.getString("title");
// String title2 = bundle2.getString("title2");
((TextView) findViewById(R.id.tvnumber)).setText(title);
// ((TextView) findViewById(R.id.tvname)).setText(title2);
using this code as it is now it sends one bundle (number) no problem, if anyone knows how i can send the other (name) it would really help me. Thanks in advance...
You can send more then one bundle
but for your need from current scenario you don't need it, Just use one,
Try this, there is no need to 2 bundle,
In activity A,
Intent i = new Intent(this, options_Page.class);
i.putExtras("title", number1.getText().toString());
i.putExtras("number", number2.getText().toString());
startActivity(i);
In activity B,
String value1 = getIntent().getExtras("title");
String value2 = getIntent().getExtras("number");
or
Bundle extras = getIntent().getExtras();
if (extras == null) {
return;
}
String value1 = extras.getString("title");
String value2 = extras.getString("number");
Thanks.