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 completely 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="com.phonegap.DroidGap"
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
</activity>
</application>
This 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.com/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 command now exits the app completely it does not return to the previous page. If you want to go back a page you should use navigator.app.backHistory()."
精彩评论