What is the equivalent operation within an activity to navigating away from the screen. Like when you press the back button, the activity goes out of view. How can this be called from inside an activity so that it closes itself.
On Clicking the back button from the New Activity, the finish() method is called and the activity destroys and returns to the home screen.
Use finish(); in Activity class to stop Activity and return.
In Activity [A], on button click, I am calling Activity [B] without finishing Activity [A]. Now in Activity [B], there are two buttons, New and Modify. When the user clicks on modify then pop an activity [A] from the stack with all the options ticked..
use 'System. exit(0);' when you really want to exit the app.
What about the Activity.finish()
method (quoting) :
Call this when your activity is done and should be closed.
you can use this.finish() if you want to close current activity.
this.finish()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With