How do you call the main launcher activity from another activity?
android, android-intent, program-entry-point
Solution
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Let's say your activity stack is as follows... MainActivity > Activity1 > Activity2> Activity3, Running the code above will close activities 1 & 2 and resume MainActivity
Problem
In my program I have an activity that gets launched when the application opens. If I open a couple more activities, how can I go back to the main activity? In the intent filter, the name of the activity is "android.intent.action.MAIN", and it will not allow me to call startActivity() on it. What do I do?