[android-developers] Re: Destroy WebView without leaking window

2012-06-23 Thread Pent
Thanks for your response.

 accomplish? I'm asking because these dialogs are modal. All interaction and
 app reactions are meant to take place within the scope of that dialog until
 *the user* makes it disappear by pressing a button. It is pretty unusual
 that the activity wants to finish while a dialog is still open.

The user pre-configures a timeout by which he wants the javascript
execution to have ended, that's what I'm trying to implement.

 Another thing comes to my mind. The last time I had to play around with
 WebView (about a year ago) there was actually no alert popup support out of
 the box.

It's definitely there now.

 I don't know whether the latest API versions changed something about that
 but you must be using a WebView which has an overridden, customized
 WebChromeClient that is responsible for creating these JavaScript alert
 dialogs in the first place.

No, you can just put an alert('hello') in, at least on my Nexus S
4.0.4.

 So whatever code you are using there must be custom WebChromeClient that
 creates the dialog. Look for that code and change it in a way so you can
 dispose the dialog prior finishing the activity.

I'd prefer to use the default implementation, but I guess if I can't
solve the problem I could
implement the dialogs myself, thanks for the tip.

I tried putting a JS setTimeout() at the start of the script BTW but
alerts seem to take over the timer.

Pent

p.s. I'm not a JS programmer if that's not obvious :-)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Destroy WebView without leaking window

2012-06-23 Thread Pent
I decided to implement the three dialog functions so I can cleanly
remove the dialog if necessary, it's not particularly complicated it
seems. Probably better backwards compatibility too.

Pent

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Destroy WebView without leaking window

2012-06-22 Thread Pent
Have you tried subclassing WebView and calling super.destroy() from
onDetachedFromWindow()?

Calling webView.destroy() is not a problem, I do that before calling
finish() on the activity.

Nevertheless I tried what you suggest with the same result,
unfortunately.

Even after the webView.destroy() call, and confirmation in the system
log:

D/webviewglue(17480): nativeDestroy view: 0x739ae8

The javascript dialog is still visible.

Pent

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Destroy WebView without leaking window

2012-06-22 Thread Nobu Games
I need to ask why are you trying to do that or what are you trying to 
accomplish? I'm asking because these dialogs are modal. All interaction and 
app reactions are meant to take place within the scope of that dialog until 
*the user* makes it disappear by pressing a button. It is pretty unusual 
that the activity wants to finish while a dialog is still open.

So what happens in the background? What is the purpose of your activity and 
why does it finish while a JavaScript alert dialog is still open?

Another thing comes to my mind. The last time I had to play around with 
WebView (about a year ago) there was actually no alert popup support out of 
the box. You had to implement the dialog for yourself using a 
WebChromeClienthttp://stackoverflow.com/questions/2979291/alert-in-embedded-webview

I don't know whether the latest API versions changed something about that 
but you must be using a WebView which has an overridden, customized 
WebChromeClient that is responsible for creating these JavaScript alert 
dialogs in the first place.
I just whipped up a test application to verify that on Android version 
4.0.1.

So whatever code you are using there must be custom WebChromeClient that 
creates the dialog. Look for that code and change it in a way so you can 
dispose the dialog prior finishing the activity.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en