Reputation: 1211
I have a question:
I have a list (for example with Names from my friends) in activity "a". When i click on one of the names(example: peter) i want to start a new activity "b". At this activity i want to show number, birthday ... from this person (peter).
Intent intent = new Intent(this, activityb.class);
startActivity(intent);
Can I insert here a parameter?
How knows activity "b" that activity a clicked the name peter.... ? I dont have any idea.... Normally i will save it with a special parameter for my function... But this is activity.....
Upvotes: 1
Views: 80
Reputation: 14505
try it:
Intent intent = new Intent(this, activityb.class);
intent.putExtra("Tag", YourClassImplementsParcelable);
startActivity(intent);
and in onCreat at activityb:
Intent intent = getIntent();
YourClassImplementsParcelable variable = (YourClassImplementsParcelable) intent.getParcelableExtra("Tag");
Upvotes: 1
Reputation: 18759
You can add extra values to the intent in activity A by using putExtra() and use getStringExtra() (or getLongExtra(), getIntExtra(), etc.) to retreive them in activity B
Take a look at this page: http://developer.android.com/reference/android/content/Intent.html
// Activity A
intent.putExtra("SOMENAME", "SomeString"); // Doesn't have to be a String ofcourse
// Activity B
String s = (String) getIntent().getStringExtra("SOMENAME");
Upvotes: 0