Issue
I am experiencing difficulties with webviews. I have a webview that loads webppage with a form. The form has a target _blank attribute. I need the webview to open a new webview window with the form's action url loaded. I have applied the following code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
web = (WebView) findViewById(R.id.webview1);
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
web = new WebView(this);
WebSettings settings = web.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
web.loadUrl("https://www.example.com/formpage");
web.setWebViewClient(new myWebClient());
web.setWebChromeClient(new WebChromeClient()
{
/* multiple webview window overload method - start */
public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, Message resultMsg)
{
WebView newWebView = new WebView(view.getContext());
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(newWebView);
resultMsg.sendToTarget();
return true;
}
/* multiple webview window overload method - end */
});
setContentView(web);
}
Nothing happens when I click on the forms submit button.
Solution
You need to insert your new WebView into the view hierarchy.
Answered By - ksasq
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.