0

just want to ask on how to call the Back button of an android phone to go back to previous screen or transaction? because as I hit on the back button of the device the application totally closes. I am building the application through eclipse with PhoneGap.

Could you guys give me an example code or function on how to call the back button to go to previous page?

Thank you guys for your big help.

  • http://stackoverflow.com/questions/3141996/android-how-to-override-the-back-button-so-it-doesnt-finish-my-activity – Orkun Feb 26 '12 at 23:45
  • @Zortkun, sorry for my newbie question. but where should I put the codes that was indicated on the link that youve suggested, should I put it on my index.html? sorry. im only a beginner. but super thank you for you response. – Frustrated Developer Feb 26 '12 at 23:56
  • Well.. I guess it s a different case, cos you are using _PhoneGap_ (which I hadnT heard of). That wonT apply to you if you cannot make changes to _java_ sources (i donT know if you can/cannot). – Orkun Feb 27 '12 at 00:04
  • but where should I put those codes to try out? which part? – Frustrated Developer Feb 27 '12 at 00:18
  • In the activity class.. but really, I cannot help you man. u are gonna have to Check out tutorials and keep googling. Good luck. – Orkun Feb 27 '12 at 00:30

1 Answers1

0

If there is nothing to go back to (ie. if the current Activity is the only one in the Stack), the app will close (that is the way Android is designed to work).

You can call finish() in your Java code (not sure about PhoneGap) to automatically go to the previous Activity.

Good Luck. (Don't forget to mark correct)

Booger
  • 18,579
  • 7
  • 55
  • 72