完全关闭一个phonegap android应用



如何完全关闭PhoneGap Android应用程序?我试过使用device.exitApp()以及navigator.app.exitApp(),两者都有同样的问题。

问题是我有一个html文件,index.html,链接到外部html文件,main.html。如果我点击关闭按钮而不打开外部文件,应用程序就会正常关闭。如果我转到外部文件,然后回到index,然后点击close,它会关闭index,但会打开main。无论我是否进入外部页面,我如何完全关闭应用程序?

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清单

<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>

这是PhoneGap Android与PhoneGap 1.0.0的工作方式。

此行为已更改为更像您在PhoneGap 1.1.0中所期望的。试着升级。

http://simonmacdonald.blogspot.com/2011/10/changes - - phonegap - android - 110. - html

"现在,当你处理多页面应用时,navigator.app.exitApp()会发生变化。这个命令现在完全退出应用程序,它不会返回到上一页。如果你想返回一个页面,你应该使用navigator.app.backHistory()。"

最新更新