2011-09-14 133 views
9

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

问题是我有一个html文件index.html,它链接到一个外部html文件main.html。现在,如果我点击关闭按钮而不去外部文件,应用程序关闭就好了。如果我去到外部文件,然后回到索引然后点击关闭,它会关闭索引,但会引起主要。无论我是否转到外部页面,如何完全关闭应用程序?

的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> 
+0

这不是Android的工作原理。您可能会打开第二个活动实例。 – Falmarri

+0

你是什么意思?我拥有的唯一活动是默认活动和droidgap活动,以便外部链接可以正常工作。如果没有droidgap活动,外部链接不会做任何事情。 – Sathariel

回答

5

这是PhoneGap的Android的如何与PhoneGap的1.0.0工作。

此行为已更改为更像您在PhoneGap 1.1.0中所期待的内容。尝试升级。

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

“现在,当你在那里处理多个页面Apps是一个变化navigator.app.exitApp()。现在,此命令退出应用程序完全不返回到前一页。如果你想要返回一个页面,你应该使用navigator.app.backHistory()。“

+0

有趣。感谢更新。 – Sathariel

+1

需要额外注意的是,在AndroidManifest.xml文件中,您必须将''设置为小于5(例如:2),直到它们修复为1.2.0。 – Devgeeks

+0

谢谢@Devgeeks。我正在使用navigator.app.exitApp(),它似乎没有记录?它不起作用。小于5的为我工作。 – Navarr

相关问题