How do I find the instance of an activity?

How do I find the instance of an activity?
Answer
4 Answers
  1. Write in your secondary class something like below: public Class SecondClass { private static WeakReference<Activity> mActivityRef; public static void updateActivity(Activity activity) { mActivityRef = new WeakReference<Activity>(activity); }
  2. Then in onCreate(Bundle) method of your Activity class:
 

Tìm kiếm

Back
Top