Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3989708
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:24:25+00:00 2026-05-20T06:24:25+00:00

I implement the many things using the webViewClient like onUnhandledKeyEvent,shouldOverrideUrlLoading and more.If want to

  • 0

I implement the many things using the webViewClient like onUnhandledKeyEvent,shouldOverrideUrlLoading and more.If want to add the support for alertbox then need to switch to WebChromeClient then i can not do other things.Any one know how mix the both future?
I have check the code for javasript alert box at http://lexandera.com/2009/01/adding-alert-support-to-a-webview/

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:24:25+00:00Added an answer on May 20, 2026 at 6:24 am

    Implement the WebViewClient and WebChromeClient both like this

    webView = (WebView) findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    
    progressBar = new ProgressDialog(this);
    progressBar.setCancelable(true);
    progressBar.setMessage("Loading...");
    progressBar.show();
    
    final Context mapp = this;
    
    webView.setWebViewClient(new WebViewClient() {
    
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        Log.i("TEST", "Processing webview url click...");
        // to kill activity
        view.loadUrl(url);
        return true;
    }
    
    public void onPageFinished(WebView view, String url) {
        Log.i("TEST", "Finished loading URL: " + url);
        if (progressBar.isShowing()) {
             progressBar.dismiss();
        }
    }........
    

    then implement the WebChromeClient for
    javascript alert,confirm and prompt

     webView.setWebChromeClient(new
     WebChromeClient() {            
     @Override
     public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result) {
        new AlertDialog.Builder(mapp)
            .setTitle(R.string.title_dialog_alert)
            .setMessage(message)
            .setPositiveButton(android.R.string.ok,
                new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        result.confirm();
                    }
                }).setCancelable(false).create().show();
    
            return true;
     }
    
     @Override
     public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(mapp)
            .setTitle(R.string.title_dialog_confirm)
            .setMessage(message)
            .setPositiveButton(android.R.string.ok,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                    result.confirm();
                }
            }).setNegativeButton(android.R.string.cancel, 
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    result.cancel();
                }
            }).create().show();
        return true;
    }
    
     @Override
         public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
              final LayoutInflater factory = LayoutInflater.from(mapp);
              final View v = factory.inflate(R.layout.javascript_prompt_dialog, null);
    
              ((TextView)v.findViewById(R.id.prompt_message_text)).setText(message);
              ((EditText)v.findViewById(R.id.prompt_input_field)).setText(defaultValue);
    
               new AlertDialog.Builder(mapp)
                    .setTitle(R.string.title_dialog_prompt)
                    .setView(v)
                    .setPositiveButton(android.R.string.ok,
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int whichButton) {
                                   String value = ((EditText)v.findViewById(R.id.prompt_input_field)).getText().toString();
                                   result.confirm(value);
                             }
                })
                .setNegativeButton(android.R.string.cancel,
                       new DialogInterface.OnClickListener() {
                             public void onClick(DialogInterface dialog, int whichButton) {
                                   result.cancel();
                             }
                 })
                 .setOnCancelListener(
                       new DialogInterface.OnCancelListener() {
                             public void onCancel(DialogInterface dialog) {
                                   result.cancel();
                             }
                 })
                 .show();
    
                 return true;
            };
    
     });
    

    for more details please check out http://code.google.com/p/mosembro/source/browse/trunk/src/com/lexandera/mosembro/Mosembro.java

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a one-to-many relationship using NHibernate 2.1.2 but keep getting
What's the best way implement MS SQL full-text search using all the normal things
This is a follow-up to my questions here: How to implement a many-to-many hierarchical
Many GDI+ classes implement IDisposable, but I'm not sure when I should call Dispose.
Many PHP systems will implement object types (such as Models) that allow a client
How to implement a search form in a many to many relation between entities.
How many types of cache is there in asp.net and how can implement it
Predictive typing is a handy feature on many mobile phones. How would/can you implement
I have a Class, it will be implemented to be many instances. I want
I am planning to implement C++-like constructor/destructor functionality to one of my Python classes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.