The application starts and A activity appears (initial activity). Pressing a button in the activity A , we get into the activity B. In activity B , there is a button to return to activity A (I used the Intent function of the button). Press the button and get into activity A , that is, the initial activity. Then click Back, get into activity B. I would not want to get into activity B when I click Back, but quit the application. How can I do that?
What I've done?
Suppose we are in activity B , which is from A. Pressing the button in B , we got into activity A. The last function that worked for B was onStop() . In this function, I called onDestroy () to remove it. But the application displayed an error.
onDestroy()is a life cycle method that is called by the system whenonDestroy()is destroyed, so that the programmer can perform any actions when this event occurs, he doesn’t delete anything and cause it (for bypassing the system) forcibly causing problems - pavlofffintentfor what you prescribe it? Usefinish()instead ofintentin Activate B and by pressing the BACK button in Activate A, the application will close. - Tommy