Closed ubergeekzone closed 5 years ago
First, you should read the official documentation on Android’s WebChromeClient
and its method onCreateWindow
, which you should implement as you’ve seen and which should be called by the OS.
Next, try logging something inside that onCreateWindow
callback to see if it’s actually called when you want to open a new window.
The official documentation on that method reads as follows:
Request the host application to create a new window. If the host application chooses to honor this request, it should return
true
from this method, create a newWebView
to host the window, insert it into the View system and send the suppliedresultMsg
message to its target with the newWebView
as an argument. If the host application chooses not to honor the request, it should returnfalse
from this method. The default implementation of this method does nothing and hence returnsfalse
. […]resultMsg
|Message
| The message to send when once a newWebView
has been created.resultMsg.obj
is aWebView.WebViewTransport
object. This should be used to transport the newWebView
, by callingWebView.WebViewTransport.setWebView(WebView)
.
So that explains all but the first two lines inside the callback, right? And in the first two lines, you should just create a new WebView
and insert it into the hierarchy of views. Does that make sense? You don’t have to use the lines exactly as shown. Feel free to adjust them so that you can create your WebView
and insert the view. Thus, instead of MyNewActivity.this
, you can just use this
from your current Activity
, e.g. MyActivity.this
.
Does that help?
I took a look at the multi-window sample code you provided and i am confused a little bit,
Could you explain how to use multi window support a little more?