How to exit from an application?

2,836 views
Skip to first unread message

Pab .Net

unread,
Aug 23, 2011, 2:19:36 AM8/23/11
to phonegap
Hi,



I would like to know how to exit from an application, i tried with
navigator.app.exitApp(); in

<a href="#" class="btn large" onclick="navigator.app.exitApp();">Exit</
a>

which results in following error

D/PhoneGapLog( 1246): file:///android_asset/www/phonegap.1.0.0.js:
Line 604 : Error: Status=2 Message=Class not found
I/Web Console( 1246): Error: Status=2 Message=Class not found at
file:///android_asset/www/phonegap.1.0.0.js:604

is that any other way to exit from app?


thanks,
-pab

Simon MacDonald

unread,
Aug 23, 2011, 9:22:39 AM8/23/11
to phon...@googlegroups.com
Hmmm...that doesn't make sense. Do you have:

<plugin name="App" value="com.phonegap.App"/>

In your plugins.xml?

Are you making sure you get the deviceready event before you try to leave the app?

Simon Mac Donald
http://hi.im/simonmacdonald


--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

Pab .Net

unread,
Aug 24, 2011, 9:23:27 AM8/24/11
to phonegap
Hi Simon,


I placed <plugin name="App" value="com.phonegap.App"/>
in plugins.xml

i called exit app in .js as

function exitAppl()
{
navigator.app.exitApp();
}

i am getting following error

E/Web Console( 542): TypeError: Result of expression
'navigator.app' [undefined] is not an object. at file:///android_asset/www/main.js:279

could u say me solution regarding this

thanks,
-pab

Giovesoft

unread,
Aug 24, 2011, 11:26:51 AM8/24/11
to phonegap
I use navigator.device.exitApp();

Simon MacDonald

unread,
Aug 25, 2011, 12:52:55 PM8/25/11
to phon...@googlegroups.com
What does your plugins.xml look like it seems like your setup is very
messed up for it not to have been in there in the first place.

David

unread,
Sep 23, 2011, 12:56:09 AM9/23/11
to phonegap
Do you have phonegap.js included?
<script type="text/javascript" charset="utf-8" src="phonegap.js"></
script>

David

unread,
Sep 23, 2011, 1:56:02 AM9/23/11
to phonegap
Is navigator.device.exitApp(); supported on all device types/
platforms?

Rajan Verma

unread,
Sep 23, 2011, 3:29:07 AM9/23/11
to phonegap
I have the same issue. i want to exit the application in android
device. I am using PhoneGap with it. Also used Backbutton as defined
on the phonegap website to exit the application. Following is the
code :

<html>
<head>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></
script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready",onDeviceReady,false);

function onDeviceReady(){
document.addEventListener("backbutton",onBackKeyDown,true);
}

function onBackKeyDown(){
navigator.device.exitApp();
}

</script>
</head>

<body>
<form>
<input type=button value="Exit" onclick="onBackKeyDown();">
</form>
</body>

But onclick of exit button, the following message displayed on logcat
viewer.
TypeError : Result of Expression 'navigator.device' [undefined] not an
object at file:///android_asset/www/index.html

Please reply. I am stuck of this.

Thanks

Simon MacDonald

unread,
Sep 23, 2011, 11:40:19 AM9/23/11
to phon...@googlegroups.com
Try "navigator.app.exitApp()" as that is where the function lies in PhoneGap 1.0.

Scott Lin

unread,
Jul 6, 2012, 7:11:41 PM7/6/12
to phon...@googlegroups.com
device.exitApp();

Alastair Gilfillan

unread,
Jul 7, 2012, 12:14:59 PM7/7/12
to phon...@googlegroups.com
Apple want to make the most of the button.


iOS applications stop when people press the Home button to open a different application or use a device feature, such as the phone. In particular, people don’t tap an application close button or select Quit from a menu.

Never quit an iOS application programmatically because people tend to interpret this as a crash.
 
So; no. The sort of person that uses iOS will think your "Exit" button is causing crashes...
Reply all
Reply to author
Forward
0 new messages