Reputation: 2019
I a starting an Activity from a non-Activity class using the context. The Activity starts fine, but I need its instance immediately after the start up. Is there any way to the instance?
Here's what my code looks like:
Intent intent = new Intent(MyApp.getAppContext(), MyActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MyApp.getAppContext().startActivity(intent);
Activity a = ???
doSomethingWithInstace(a);
Upvotes: 0
Views: 80
Reputation: 48232
You can put doSomethingWithInstance()
into your activity and call it from onCreate()
or onStart()
. Whatever data are needed your Activity can take them from the global Application
object.
Upvotes: 2