Question

I was wondering if any of you were aware of, or knew of a solution to this issue. Basically I have this function here:

  function onDeviceReady() {
     document.addEventListener("backbutton", function() {
     if (getObj("btnBack") != null){
                pui.click("btnBack");
             }
     else{ 
        navigator.device.exitApp();
     }
     }, false);
  }

where pui.click() is just something defined on my end. So this function gets called whenever the back button on my android device is pressed; on 2.9 and all versions below if this reaches a point on the app where the btnBack obj is not present, it calls navigator.device.exitApp() (or navigator.app.exitApp() I switched between the two to see if that would fix my issue) and the app closes just fine. Now with 3.0.0 I get the following fatal exception in Eclipse:

08-16 15:23:27.015: E/AndroidRuntime(22715): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@422635a8 is not valid; is your activity running?

Anyone know whats going on here? I grabbed my application with the previous version from the android market and it works just fine with the back button.

Edit:

Still having this issue months later. My activity is unchanged (there is another package being imported here that I did not include but otherwise this is my activity's source:

import android.os.Bundle;
import org.apache.cordova.*;

public class PUIClient extends CordovaActivity 
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        // Set by <content src="index.html" /> in config.xml
        super.loadUrl(Config.getStartUrl());
        //super.loadUrl("file:///android_asset/www/index.html")
    }
}

Edit:

Here is the logcat screenshot; it loosk like this is being caused by the onMessage call internally. It seems something internally is trying to send that message while the application is closing down. enter image description here

Was it helpful?

Solution 2

After looking through the Notifications.java file that comes from the Dialogs plugin, I found that adding the following isFinishing() check has solved my problem. I am not sure what is causing a notification to be executed when I quit the application, but a simple check as highlighted in my screenshot negates that last alert and my app closes smoothly. I had this issue for months starting at version 2.9; hopefully this helps someone in a similar bind. See red highlighted box

OTHER TIPS

Without the full code it is hard to tell where the problem is :(

Check if you are making some alerts or calls inside getObj("btnBack").

Did you change something iside your activity?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top