0

I'm displaying a webpage in a WebView and on the webpage, there is a button. When you click the button, a confirmation dialog is supposed to popup, but it doesn't show in my WebView. It does popup if I go to the same webpage in the android browser. Anyone know how to handle popup dialogs coming from a webpage inside your WebView?

this my code

public class MainActivity extends AppCompatActivity {

    private WebView webv;
    private ProgressBar progressBar;
    private String url = "https://www.k.com";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webv = (WebView) findViewById(R.id.webview);

        webv.setWebViewClient(new WebViewClient());
        webv.getSettings().setJavaScriptEnabled(true);
        webv.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
        webv.getSettings().setDomStorageEnabled(true);
        webv.getSettings().setSupportMultipleWindows(true);


        WebSettings webset = webv.getSettings();
        webset.setJavaScriptEnabled(true);
        webv.loadUrl(url);

        webv.getSettings().setBuiltInZoomControls(true);
        webv.getSettings().setSupportZoom(true);



    }




    @Override
    public void onBackPressed() {
        if (webv.isFocused() && webv.canGoBack()) {
            webv.goBack();
        } else {
            super.onBackPressed();
            finish();
        }
    }
}

1 Answers1

0

This was answered here:

JavaScript alert not working in Android WebView

And the solution is setting webChromeClient:

webv.setWebChromeClient(new WebChromeClient());
Community
  • 1
  • 1
Eder Martins
  • 111
  • 1
  • 5