How do I fully close a PhoneGap Android app? I've tried using device.exitApp() as well as navigator.app.exitApp() and have the same problem with both.
The problem is that I have an html file, index.html, that links to an external html file, main.html. Now if I hit the close button without going to the external file, the app closes just fine. If I go to the external file and then go back to index then hit close, it closes index but brings up main. How do I pletely close the app whether or not I go the external page?
Index.html
<html>
<head>
<script type="text/javascript" src="Scripts/phonegap-1.0.0.js"></script>
</head>
<body>
<a href="index.html">Index</a>
</body>
</html>
Main.html
<html>
<head>
<script type="text/javascript" src="Scripts/phonegap-1.0.0.js"></script>
</head>
<body>
<a href="index.html">Index</a>
</body>
</html>
Android Manifest
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".TestActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".phonegap.DroidGap"
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
</activity>
</application>
How do I fully close a PhoneGap Android app? I've tried using device.exitApp() as well as navigator.app.exitApp() and have the same problem with both.
The problem is that I have an html file, index.html, that links to an external html file, main.html. Now if I hit the close button without going to the external file, the app closes just fine. If I go to the external file and then go back to index then hit close, it closes index but brings up main. How do I pletely close the app whether or not I go the external page?
Index.html
<html>
<head>
<script type="text/javascript" src="Scripts/phonegap-1.0.0.js"></script>
</head>
<body>
<a href="index.html">Index</a>
</body>
</html>
Main.html
<html>
<head>
<script type="text/javascript" src="Scripts/phonegap-1.0.0.js"></script>
</head>
<body>
<a href="index.html">Index</a>
</body>
</html>
Android Manifest
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".TestActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".phonegap.DroidGap"
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
</activity>
</application>
Share
Improve this question
edited Mar 4, 2012 at 13:31
Waynn Lue
11.4k8 gold badges52 silver badges77 bronze badges
asked Sep 14, 2011 at 22:30
SatharielSathariel
3502 gold badges5 silver badges13 bronze badges
2
- That's not how android works. You're probably opening a second instance of your activity. – Falmarri Commented Sep 14, 2011 at 22:48
- What do you mean? The only activities that I have are the default one and the droidgap one so that external links can work. Without the droidgap activity, the external links doesn't do anything. – Sathariel Commented Sep 14, 2011 at 23:54
1 Answer
Reset to default 5This was how PhoneGap Android worked with PhoneGap 1.0.0.
This behaviour has changed to more like what you are expecting in PhoneGap 1.1.0. Try upgrading.
http://simonmacdonald.blogspot./2011/10/changes-in-phonegap-android-110.html
"Now when you are dealing with multiple page apps there is a change to navigator.app.exitApp(). This mand now exits the app pletely it does not return to the previous page. If you want to go back a page you should use navigator.app.backHistory()."