Search code examples
androidandroid-activityflagsstart-activity

Start new Activity and finish current one in Android?


Currently I'm starting a new Activity and calling finish on a current one.

Is there any flag that can be passed to Intent that enables finishing current Activity without a need to call finish manually from code?


Solution

  • You can use finish() method or you can use:

    android:noHistory="true"
    

    And then there is no need to call finish() anymore.

    <activity android:name=".ClassName" android:noHistory="true" ... />