Ted pottel
Ted pottel

Reputation: 6993

Is there a way to write code to go to the previous activity?

Right now in my android app a user presses a button to go to another activity, and then must press the back button on android to return to the previous activity. Can I have a button on my app and write code to go to the previous activity?

Upvotes: 0

Views: 345

Answers (2)

Aman Aalam
Aman Aalam

Reputation: 11251

As the easiest way, you code write a code where your current activity is closed on a particular event, say on a button press. the method to be called is finish()

This way, when your current activity is finished, you are taken back to your previous activity.

Upvotes: 6

Kartik Domadiya
Kartik Domadiya

Reputation: 29968

Yes Ofcourse. : See the vogella article

Upvotes: 1

Related Questions