I am trying to use Webview
in Android and facing the below difficulty while accessing a site which requires authentication in pop up as soon I launch it.
When the app runs, Webview
displays blank page instead of the popup or the authentication page.
Note: loading other webpages are fine. e.g "google" "facebook"
Java code
public class MainActivity extends AppCompatActivity {
private WebView webview1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initialize();
}
private void initialize() {
webview1 = (WebView) findViewById(R.id.webview1);
webview1.setVisibility(View.VISIBLE);
webview1.loadUrl("http://164.100.194.110:81");
webview1.setWebChromeClient(new WebChromeClient(){
@Override
public boolean onJsAlert(WebView view, String url, String message,JsResult result) {
webview1.loadUrl(url);
return super.onJsAlert(view, url, message, result);
}
});
webview1.getSettings().setJavaScriptEnabled(true);
webview1.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview1.getSettings().setSupportZoom(true);
webview1.getSettings().setSupportMultipleWindows(true);
webview1.setWebViewClient(new WebViewClient() {
public void onPageStarted(WebView view, final String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
public void onPageFinished(WebView view, final String url) {
super.onPageFinished(view, url);
}
});
}
}