necixy
necixy

Reputation: 5064

Android: new class variable initialization

I have two classes(activites) in android:

  1. ProfileScreen.
  2. FillDetailScreen.

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

Answers (2)

Dinesh Sharma
Dinesh Sharma

Reputation: 11571

Simply declare the class variable static and initailze them in the ProfileScreen class using FillDetailsScreen.varName=value .

Upvotes: 0

Vladimir Ivanov
Vladimir Ivanov

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

Related Questions