Passing Data Between Activities Problem!

Put your problem here if it does not fit any of the other categories.

Passing Data Between Activities Problem!

Postby mr_muskuraha » Mon Jan 25, 2010 10:55 am

dear friends,

can any one guide me what mistake am i doing in this code??? it not seems to be working..

i have two activies

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


Intent intent = new Intent(DataPassing.this, DataPassing2.class);
Bundle b = new Bundle();

b.putInt("key", 1123);

intent.putExtras(b);

startActivity(intent);

finish();
}

and in second activity i have written

public void onCreate(Bundle savedInstanceState) {
Bundle b = getIntent().getExtras();

int value = b.getInt("key", 0);

Toast.makeText(this, value, Toast.LENGTH_SHORT).show();


}

but the code is giving me error i dont know why.. i have added second activity to manifest file.. please guide what mistake i am doing ???

any help would be appriciated..
mr_muskuraha
Senior Developer
Senior Developer
 
Posts: 142
Joined: Wed Jan 13, 2010 8:49 am

Top

Postby nicholas.hauschild » Mon Jan 25, 2010 2:18 pm

Hello mr_muskuraha,

If you are developing using Eclipse, you should be able to see the exception being thrown in LogCat, and that would be the best place to start looking for help. If you still need help after that, please post the stacktrace you find from LogCat.

Good luck!
nicholas.hauschild
Master Developer
Master Developer
 
Posts: 310
Joined: Fri Dec 04, 2009 4:50 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 20 guests