A.java:
public class A {
public static StartActivity startActivity;
}
B.java:
public class StartActivity extends Activity
public void onCreate(Bundle savedInstanceState) {
A.activity = this;
}
}
From the 2 java files above, I would like to ask what is the meaning of a.activity = this;?
Do that mean create a new instance of activity?
No. activity is a field, not an class, and you can’t create an “instance” of a variable, just of classes. All that code is doing is assigning an already existing object (the current b object) to a’s static field, activity, that’s all.
Edit
Correction, I suppose activity is also a class since you have both a type and a variable given the same name, activity? Your naming is non-standard which is confusing the issue and your question greatly. I suggest you change your question and make the naming standard and non-confusing. All types including classes, interfaces and enums should begin with an uppercase letter and all variables with a lowercase letter.
Edit 2
OK, after reviewing your latest code in your edited question, we see that A has a static StartActivity field, also known as a static variable, called Activity. Inside of class B’s
onCreate(...)method it assignsthis, the reference to the current B object itself, to A’s activity field. So if activity was assigned to a prior StartActivity object, that assignment has now been changed to the current B object if itsonCreate(...)method is called.