4

I am currently using PhoneGap build 2.9.0 to create a simple app and I was wondering if it's possible to create a button that will take the user outside of your application and the phones default home screen.

I am trying to emulate a close button, I realise that you can't close applications with iOS however you can with android and blackberry i think. So my workaround is to try and redirect to the users default home screen on their phone (rather than force closing the application)

Any ideas?

pleshy
  • 1,468
  • 2
  • 16
  • 22

2 Answers2

1

You really shouldn't have a close(stop) button in Android - the OS was designed to close apps on its own. For Android you can use:

navigator.device.exitApp();

Here is more info on the matter: http://community.phonegap.com/nitobi/topics/how_to_exit_from_the_phonegap_app_on_android_and_ios

inf1ux
  • 283
  • 1
  • 14
  • I find it pretty useful especially the google navigation app on android there is an exit application button. However I am not wanting to exit my application just returning the users default home screen while still leaving the application running in the background – pleshy Jul 19 '13 at 14:05
  • Then please look here - [link](http://stackoverflow.com/a/11459332/1619821) Maybe you can try to hack it using the [backbutton](http://docs.phonegap.com/en/1.8.1/cordova_events_events.md.html#backbutton) event. – inf1ux Aug 26 '13 at 07:25
1

On iOS, Apple does not allow apps to programmatically exit.

Hope this will help.

Rajeev Barnwal
  • 1,349
  • 11
  • 14
  • I am not wanting the app to exit :) just to go to the default home screen of the phone (most smartphone have similar screens), this like I said is a work around for iOS – pleshy Jul 19 '13 at 14:08
  • 1
    http://stackoverflow.com/questions/5360846/suspend-the-application - you can't unless you want your app to be rejected. – Noogen Jul 19 '13 at 17:15