Issue
A similar question was asked about a year ago, and wasn't quite resolved, but I'm gonna try my luck anyhow, maybe someone knows this.
I have this application that runs a couple of HTML pages in a WebView. Everything looks nice and works OK, until you try to open a SELECT tag - boom, application crashes. Here's a trace stack, if this helps:
Thread [<1> main] (Suspended (exception WindowManager$BadTokenException)) AlertDialog(Dialog).show() line: 247
WebView$InvokeListBox.run() line: 7841
WebView$PrivateHandler(Handler).handleCallback(Message) line: 587
WebView$PrivateHandler(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 130 ActivityThread.main(String[]) line: 3859
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 507
ZygoteInit$MethodAndArgsCaller.run() line: 840
ZygoteInit.main(String[]) line: 598 NativeStart.main(String[]) line: not available [native method]
(What does AlertDialog have to do with opening a select box is beyond me. And no, there's no script associated with the SELECT that opens an Alert).
Now, here's the best part. I'm testing the app on 2 devices, Samsung Galaxy S2 with OS 2.3.3, and Motorola RAZR XT910 with OS 2.3.5. On Samsung everything works wonderful. On RAZR, however, the above happens.
The pages are pretty heavy with CSS and JavaScript, but it's crashing even if everything is removed. In fact, an empty HTML with a single SELECT control still crashes. A few things mentioned in the question from year ago that I did try:
- Removing all absolute and fixed positioned elements from the HTML (in fact I removed the entire CSS just to see if it has any effect - it doesn't).
- Ensuring the SELECT is written by-the-book, no bogus attributes / tags.
Nothing helped.
Does anyone have the slightest clue as to what might be causing this?
Solution
After looking all over the web for over a month, I've given up and relayed all SELECTs to native code.
Replace the SELECT with something that looks like SELECT, bind click handler that launches a method on JavascriptInterface
and pass the SELECTs option values to it, let the method open a Dialog
with a RadioGroup
, fill the group with RadioButton
s representing the options. When selected, resolve the index and pass it back to the JavaScript (the SELECT instance that launched the process should be saved in some var first).
This is ugly as hell, but sadly nothing else seemed to work.
Answered By - Igor K.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.