Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fully Closing a phonegap android app

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>
like image 893
Sathariel Avatar asked Sep 14 '11 22:09

Sathariel


1 Answers

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()."

like image 117
Devgeeks Avatar answered Oct 22 '22 14:10

Devgeeks