rahul rahul - 1 year ago 110
Android Question

how to finish all activities and close the application in android?

My application has the following flow

Home->screen 1->screen 2->screen 3->screen 4->screen 5>Home->screen 2->Home->Screen 3

My problem is that when I am trying to close the application then Home activity opens everytime when I am trying to close the application.

I just wants to close the application when user presses the back key of device on home screen.

Answer Source

there is finishAffinity() method that will finish the current activity and all parent activities, but it works only in Android 4.1 or higher

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download