Reputation: 1765
I have a back button that will work exactly like that.
I know using back button is not a good android practice since android device have one. But my situation badly need it.
I cannot finish my activity and its tough to Keep track of the activity stack.
Upvotes: 1
Views: 988
Reputation: 1746
I wonder why you wouldn't want to finish your activity. Could you move whatever it is in your activity you don't want to destroy into another object?
BTW: the activity will also be destroyed and re created if the screen is rotated.
Upvotes: 0
Reputation: 5381
Since you know that overriding BACK button function is not a good practice, just follow it. Tracking activity stack and promising the BACK behavior can be solved by properly setting the launch mode of each Activity. (please see: Launch Mode in Android Official Site)
If you insist to do something like pressing the BACK button, it's super.onBackPressed()
.
Upvotes: 1
Reputation: 34823
its better for you to user super.onBackPressed()
Refer Go back to previous activity
Upvotes: 0