Reputation: 5064
I have two classes(activites) in android:
Now from activity 1 I am calling activity 2 by following code:
Intent it = new Intent(ProfileScreen.this, FillDetailsScreen.class);
startActivity(it);
But I have some class variables in FillDetailsScreen, how can I initialize them from my activity 1 that is ProfileScreen?
Upvotes: 0
Views: 771
Reputation: 11571
Simply declare the class variable static and initailze them in the ProfileScreen class using FillDetailsScreen.varName=value .
Upvotes: 0
Reputation: 43098
you should pass their values in the intent:
it.putExtra("param1", var1);
it.putExtra("param2", var2);
in FillDetailScreen:
intent = getIntent();
var1 = intent.getExtra("param1");
Upvotes: 1