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

  • Home
  • SEARCH
  • 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 8241903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:59:15+00:00 2026-06-07T20:59:15+00:00

This question has been asked before but, I’m a newbe and having issues trying

  • 0

This question has been asked before but, I’m a newbe and having issues trying to get it to work. My question is how do I get a Progress Dialog to show up everytime a user clicks a link in webview. I have a dialog that shows when the app is first started but, does not show a dialog when the links are clicked. I’m pretty sure that the solution is here , but I just cant seem to put them together properly for it to work….. Can someone please help me put this together.

My Code

See the approved anwser

  • 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-06-07T20:59:17+00:00Added an answer on June 7, 2026 at 8:59 pm

    I didn’t get any help with my problem but I finally figured it out. I’m posting an example project to help anyone with the same problem. This is a web_view project that shows a (page Loading…) dialog, every time a link is clicked. This example also checks for an Internet connection…

    Download the Eclipse project here

    Here are my two java files. The file below contains the solution for the progress dialog.

         package com.example.project;
    
    
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.app.ProgressDialog;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.net.Uri;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.Window;
    import android.webkit.WebChromeClient;
    import android.webkit.WebSettings;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.widget.Toast;
    
    public class WebActivity extends Activity {
    
        private WebView wv;
    
        private String LASTURL = "";
    
        Menu myMenu = null;
        private ProgressDialog dialog;
    
    
        /**
         * Called when the activity is first created.
         */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
    
            if (!InternetConnection.checkNetworkConnection(this)) {
                showAlert(this, "No Data Connection", "This Application requires an internet connection");
            } else {
    
                setContentView(R.layout.web_view);
    
                wv = (WebView) findViewById(R.id.web_view);
    
                WebSettings webSettings = wv.getSettings();
                webSettings.setSavePassword(true);
                webSettings.setSaveFormData(true);
                webSettings.setJavaScriptEnabled(true);
                webSettings.setUseWideViewPort(true);
                webSettings.setLoadWithOverviewMode(true);
                webSettings.setSupportZoom(false);
    
    
                final Activity activity = this;
    
                // start ProgressDialog with "Page loading..."
                dialog = new ProgressDialog(activity);
                dialog.setMessage("Page loading...");
                dialog.setIndeterminate(true);
                dialog.setCancelable(true);
                dialog.show();
    
                wv.setWebChromeClient(new WebChromeClient() {
                    public void onProgressChanged(WebView view, int progress) {
                        // set address bar and progress
                        // activity.setTitle( " " + LASTURL );
                        // activity.setProgress( progress * 100 );
    
                        if (progress == 100) {
                            // stop ProgressDialog after loading
                            dialog.dismiss();
    
                            // activity.setTitle( " " + LASTURL );
                        }
                    }
                });
    
                wv.setWebViewClient(new WebViewClient() {
                    public void onReceivedError(WebView view, int errorCode,
                            String description, String failingUrl) {
                        Toast.makeText(getApplicationContext(),
                                "Error: " + description + " " + failingUrl,
                                Toast.LENGTH_LONG).show();
                    }
    
                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        if (url.indexOf("google") <= 0) {
                            // the link is not for a page on my site, so launch
                            // another Activity that handles URLs
                            Intent intent = new Intent(Intent.ACTION_VIEW, Uri
                                    .parse(url));
                            startActivity(intent);
                            return true;
                        }
                        return false;
                    }
                    /*****************************************************************/
                    /*  Here the load of the page will start so we must launch the  */
                    /*  ProgressDialog                                              */
                    /*****************************************************************/                                             
                    public void onPageStarted(WebView view, String url,
                            Bitmap favicon) {
    
                        // this is what we should do
                        dialog.setMessage("Page loading...");
                        dialog.setIndeterminate(true);
                        dialog.setCancelable(true);
                        dialog.show();
                        //
                        LASTURL = url;
                        view.getSettings().setLoadsImagesAutomatically(true);
                        view.getSettings().setBuiltInZoomControls(true);
                    }
                    /*****************************************************************/
                    /*  Here the load of the page will stop so we must dismiss the  */
                    /*  ProgressDialog                                              */
                    /*****************************************************************/ 
                    public void onPageFinished(WebView view, String url) {
                        // this is what we should do
                        dialog.dismiss();
    
                    }
                });
                wv.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
                wv.setScrollbarFadingEnabled(false);
                wv.loadUrl("http://www.google.com");
    
            }
        }
    
        @Override
        public boolean onKeyDown(int keyCode, KeyEvent event) {
            if ((keyCode == KeyEvent.KEYCODE_BACK) && wv.canGoBack()) {
                wv.goBack();
                return true;
            }
            return super.onKeyDown(keyCode, event);
        }
        /*****************************************************************/
        /*  Here is a menu with basic options. Will probably get 
         * comments on how this is replaced by action bar               */
        /*****************************************************************/
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            super.onCreateOptionsMenu(menu);
    
            this.myMenu = menu;
            MenuItem item = menu.add(0, 1, 0, "Home");
            item.setIcon(R.drawable.home);
            MenuItem item2 = menu.add(0, 2, 0, "Back");
            item2.setIcon(R.drawable.arrowleft);
            MenuItem item3 = menu.add(0, 3, 0, "Reload");
            item3.setIcon(R.drawable.s);
            MenuItem item4 = menu.add(0, 4, 0, "Share");
            item4.setIcon(R.drawable.share);
            MenuItem item5 = menu.add(0, 5, 0, "Rate");
            item5.setIcon(R.drawable.vote);
            MenuItem item6 = menu.add(0, 6, 0, "Exit");
            item6.setIcon(R.drawable.close);
            return true;
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()) {
            case 1:
                wv.loadUrl("http://www.google.com");
                break;
            case 2:
                if (wv.canGoBack()) {
                    wv.goBack();
                }
                break;
            case 3:
                wv.loadUrl(LASTURL);
                break;
            case 4:
                Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                sharingIntent.setType("plain/text");
                sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Check out this app I found.");
                startActivity(Intent.createChooser(sharingIntent,"Share using"));
                break;
            case 5:
    
                Intent marketIntent2 = new Intent(Intent.ACTION_VIEW, Uri.parse(
                        "http://market.android.com/details?id=" + getPackageName()));
                      startActivity(marketIntent2);
                    break;
    
            case 6:
                finish();
                break;
    
            }
    
            return true;
        }
    
    
    
        /**
         * Display a simple alert dialog with the given text and title.
         * 
         * @param context
         *            Android context in which the dialog should be displayed
         * @param title
         *            Alert dialog title
         * @param text
         *            Alert dialog message
         */
        public void showAlert(Context context, String title, String text) {
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    
            // set title
            alertDialogBuilder.setTitle( title);
    
            // set dialog message
            alertDialogBuilder
            .setMessage( text )
            .setCancelable(false)
            .setPositiveButton("OK",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                    // if this button is clicked, close
                    // current activity
                    finish();
                }
            })
            .create().show();
    
        }
    }
    

    This java file checks for a Internet Connection. If no connection is available the application will close.

    package com.example.project;
    
    import android.content.Context;
    import android.net.ConnectivityManager;
    import android.net.NetworkInfo;
    
    public class InternetConnection {
    
        public static boolean checkNetworkConnection(Context context) {
    
            ConnectivityManager connectivityManager = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
    
            boolean infoResult = false;
            boolean wifiResult = false;
            boolean mobileResult = false;
    
            try {
                NetworkInfo info = connectivityManager.getActiveNetworkInfo();
                if (info == null) {
                    return false;
                } else {
                    infoResult = info.isConnectedOrConnecting();
                    }
    
                NetworkInfo wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
                if (wifi == null) {
                    return false;
                } else {
                    wifiResult = wifi.isConnectedOrConnecting();
                    }
    
                NetworkInfo mobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
                if (mobile == null) {
                    return false;
                } else {
                    mobileResult = mobile.isConnectedOrConnecting();
                    }
    
                // if(wifi.isConnectedOrConnecting()||mobile.isConnectedOrConnecting())
    
            } catch (NullPointerException nullPointException) {
                System.out.println( nullPointException.getMessage() );
            }
    
            return infoResult||wifiResult||mobileResult;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see this question has been asked before, but I still trying to get
This question has been asked before perhaps multiple times, but I can't get the
Now this question has been asked before but I am not able to get
I know this question has been asked before but the solutions did not work
I realize this question has been asked before, but I can't get it to
I know this question has been asked before but the other solutions didn't work
This question has been asked before but i still don't understand it fully so
This question has been asked before but the answers aren't always clear or are
Forgive me if this question has been asked before but I am new to
I'm not sure if this question has been asked before but are there any

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.