I Found some codes for quit an Android application programatically. By calling any one of the following code in onDestroy() will it quit application entirely?
Is quitting an application frowned upon?. Go through this link. It answers your question. The system does the job of killing an application.
Suppose you have two activities A an B. You navigate from A to B. When you click back button your activity B is popped form the backstack and destroyed. Previous activity in back stack activity A takes focus.
You should leave it to the system to decide when to kill the application.
public void finish()
Call this when your activity is done and should be closed.
Suppose you have many activities. you can use Action bar. On click of home icon naviagate to MainActivity of your application. In MainActivity click back button to quit from the application.