开发者

Android Thread in shouldOverrideUrlLoading

I had some code in a shouldOverrideUrlLoading, that downloads the data, converting if necessary, and shows i开发者_StackOverflow社区n a WebView using loadData or loadUrl. I moved this to a thread (a class implementing Runnable), and now it doesn't lock up the UI while the next page is loading. Unfortunately, sometimes it locks up the whole app, and pausing while debugging shows it seems to be going nowhere (deadlock?)

I'm guessing this is because UI isn't thread-safe, not even webkit loadData/loadUrl? Is there a way to set some sort of onFinish action that runs in UI thread after download/convert has finished? Or would it be enough to store the current thread, and cancel it before running another thread??


adding a synchronized (WebView) { around the thread's code fixes this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜