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 6746887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:22:32+00:00 2026-05-26T12:22:32+00:00

Anyone know what is going on at here? Is there any way to allow

  • 0

Anyone know what is going on at here? Is there any way to allow user to cancel the progressDialog and go back to Activity A without having any crash ?

Steps to reproduce this crash :

In an activity A and I start a new intent Activity B tabhost that load “class1.java” (Webview with progressDialog) before the progressDialog load finish , i quicky hit the back button to go back to Activity A and i got a crash

The apps won’t crash if :

  • I wait till the webview load finish and go back to Activity A

  • I cancel the progressDialog and stay on the webview till the page load finish and go back to Activity A

Line 51 : progressDialog.incrementProgressBy(progress);

Logcat : http://pastebin.com/uBw4xcaY

java.lang.NullPointerException
at com.domain.package.ui.class1$class1_$1.onProgressChanged(class1.java:51)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:358)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
at dalvik.system.NativeStart.main(Native Method)

Here’s my code :

[...]

public class class1 extends FragmentActivity {

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

}

public static class class1_ extends Fragment {

    /** The Fragment's UI **/
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.class_, container, false);

        WebView engine = (WebView) v.findViewById(R.id.web_engine);

        final ProgressDialog progressDialog;
        progressDialog = new ProgressDialog(getActivity());
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setMessage("Loading...");
        progressDialog.setCancelable(true);
        progressDialog.setProgress(0);
        progressDialog.show();

        engine.setWebChromeClient(new WebChromeClient() {

            public void onProgressChanged(WebView view, int progress) {

                progressDialog.setProgress(0);
                getActivity().setProgress(progress * 1000);

                progressDialog.incrementProgressBy(progress);

                if (progress == 100 && progressDialog.isShowing())
                    progressDialog.dismiss();
            }

        });

            engine.getSettings().setBuiltInZoomControls(false);
            engine.getSettings().setUseWideViewPort(false);
            engine.getSettings().setSupportZoom(false);
            engine.loadUrl("file:///android_asset/index.html");


        Toast.makeText(getActivity(),
                "Hello this is a toast",
                Toast.LENGTH_LONG).show();

        return v;
    }
  }
}
  • 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-26T12:22:33+00:00Added an answer on May 26, 2026 at 12:22 pm

    Try changing your onChanged() method like this:

    public void onProgressChanged(WebView view, int progress) {
      if( progressDialog.isShowing() ) {
        progressDialog.setProgress(0);
        getActivity().setProgress(progress * 1000);
    
        progressDialog.incrementProgressBy(progress);
    
        if ( progress == 100 )
          progressDialog.dismiss();
      }
    }
    

    And then add this to the fragments onPause() method:

    if( progressDialog != null && progressDialog.isShowing() )
      dialog.dismiss();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know what is going on here? When I pressed the key once,
Anyone know? I found a few answers, but there were too complex and going
Anyone know if there is a standard way to create a List from an
Does anyone know what's going to be in the next version of jquery (1.3.3
Anyone know what the best way is to search on a Field that hold
I'm new to CSS and was wondering if there was any way to stop
UPDATE: SOLVED!!! Please see the answer I added below Does anyone know if there
Anyone know how I can make a login button in Ruby on Rails for
Anyone know how to set the custom 404 Error pages that the Visual Studio
Anyone know of a tutorial online that explains how to integrate alexbilbie CodeIgniter-OAuth-2.0-Server as

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.