【发布时间】:2011-09-14 22:30:04
【问题描述】:
如何完全关闭 PhoneGap Android 应用程序?我试过使用 device.exitApp() 和 navigator.app.exitApp() 并且两者都有同样的问题。
问题是我有一个 html 文件 index.html,它链接到一个外部 html 文件 main.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>
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>
【问题讨论】:
-
安卓不是这样工作的。您可能正在打开您的活动的第二个实例。
-
什么意思?我拥有的唯一活动是默认活动和 droidgap 活动,以便外部链接可以工作。如果没有 droidgap 活动,外部链接不会做任何事情。
标签: javascript android cordova