Skip to content Skip to sidebar Skip to footer

Android Pending Exception

My app is a hybrid html5 + JS + android which run in webview and communicate so much with Andorid through JS interface. I got some report that it fails after 2 second on some devic

Solution 1:

I think the method immediatelyCalled() is called in another thread than the one you are creating "MyActivity parent" (a UI thread, your apps main thread). So an uncaught exception handler which you assign to the ui thread and which has nothing to do with the process which is running the javascript code, can not catch this exception occuring at setText (accessing a view which belongs to another thread).

I think you could catch the exception of course if you enclose parent.textview1.setText("test"); in a try catch block. You should be able to avoid the exception if you modify the setText call in this way:

parent.textView1.post(new Runnable() {
    publicvoidrun() {
        parent.textview1.setText("test");
    }
});

You'll have to mark your parent parameter as final. Unfortunately i have no eclipse here to test and it's late already :) good luck!

Post a Comment for "Android Pending Exception"