Skip to content Skip to sidebar Skip to footer

Getting Main Activity From Main Application

I have the following manifest.

Solution 1:

There is no way to retrieve the application's main Activity using the Application instance.

Usually there is no reason to do this... perhaps there is a better solution than manipulating the main Activity directly as you apparently are doing. Maybe you should update your post explaining specifically what you are attempting to do.

Solution 2:

You can start the activity form the MyMainApplication class though it doesn't extends Activity In Main Application Class create new Intent and set the intent flags to Intent.FLAG_ACTIVITY_NEW_TASK . Activity gets instantiated. I have tested and verified.

code snippet for reference :

Intent intent = newIntent(this,MyMainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Post a Comment for "Getting Main Activity From Main Application"