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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:56:47+00:00 2026-06-07T02:56:47+00:00

I’ve using AsyncTask while retrieving data from a web service. I want to a

  • 0

I’ve using AsyncTask while retrieving data from a web service. I want to a ProgressDialog to appear while I fetch the data from web server. Following is the code snippet.

I initialize progress dialog and call the async task object inside onCreate and call asynctask:

public class MyDashboardActivity extends Activity {
     ProgressDialog mProgressDialog;
     static final int LOADING_DIALOG = 0;

private FetchDashboardEntriesProcess mTask;
private boolean mShownDialog;
    private MyDashboardActivity act = null;

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.mydashboard);
mTask = new FetchDashboardEntriesProcess(MyDashboardActivity.this);
     mTask.execute(null,null,null);  
}

private class FetchDashboardEntriesProcess extends AsyncTask<Object, Void, Void> {

private MyDashboardActivity activity;
private boolean completed;



private ArrayList<DashboardEntry> returnVal = new ArrayList<DashboardEntry>();

private FetchDashboardEntriesProcess(MyDashboardActivity activity) {
    this.activity = activity;
}

public ArrayList<DashboardEntry> getAllDashboardEntry() {
    return returnVal;
}

@Override
protected void onPreExecute() {
    if (!completed) {

        activity.showDialog(LOADING_DIALOG);

    }
}

@Override
protected Void doInBackground(Object... params) {
    try {
        ServiceCall call = new ServiceCall();
        DashboardEntryCriteria bean = new DashboardEntryCriteria();
        StringBuilder dateStr = new StringBuilder();

        bean.setLoginId("300");
        returnVal = call.getDashboardEntries(bean);

    } catch (Exception e) {
        Log.d(TAG, "Exception" + e.toString());
        e.printStackTrace();
    }
    return null;

}

@Override
protected void onPostExecute(Void unused) {
    completed = true;

    notifyActivityTaskCompleted();

}

private void setActivity(MyDashboardActivity activity) {
    this.activity = activity;
    if (completed) {
        notifyActivityTaskCompleted();
    }
}
private void notifyActivityTaskCompleted() {
    if (null != activity) {
        activity.onTaskCompleted();

    }
}
}
private void onTaskCompleted() {
    Log.e(TAG, "Activity " + this
            + " has been notified the task is complete.");
    dashboardEntries = mTask.getAllDashboardEntry();
    fillDashboardEntries(dashboardEntries);

    if (mShownDialog) {
        dismissDialog(LOADING_DIALOG);

    }
}

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    super.onPrepareDialog(id, dialog);
    if (id == LOADING_DIALOG) {
        mShownDialog = true;
    }
}

@Override
protected Dialog onCreateDialog(int id) {
    // TODO Auto-generated method stub
    if (id == LOADING_DIALOG) {
        mProgressDialog = Functions.getProgressDialog(act,
                getString(R.string.all_retriving_data));
        return mProgressDialog;
    }
    return super.onCreateDialog(id);
}
}

According to the log program is interrupted at onPreExecute at the line activity.showDialog(LOADING_DIALOG); so I’m guessing the error is generated due to something being wrong with the way I create dialog. How do I get past this?

Thank you.

EDIT: Log Cat

07-02 19:41:53.433: D/dalvikvm(335): GC_EXTERNAL_ALLOC freed 61K, 52% free 2600K/5379K,   external 1625K/2137K, paused 79ms

 07-02 19:41:58.214: I/myproject(335): Activity com.myproject.activities.LoginActivity@405293b0 has been notified the task is complete.
 07-02 19:41:58.745: D/dalvikvm(335): GC_EXTERNAL_ALLOC freed 271K, 52% free 2721K/5639K, external 3579K/3826K, paused 152ms

 07-02 19:41:59.644: E/RESULT:(335): GetDashboardEntriesResponse{GetDashboardEntriesResult=anyType{}; }

 07-02 19:41:59.654: E/Some Exception(335): Some Exception
 07-02 19:41:59.664: W/System.err(335): java.lang.NullPointerException
 07-02 19:41:59.664: W/System.err(335):     at android.app.Dialog.<init> (Dialog.java:141)
07-02 19:41:59.664: W/System.err(335):  at android.app.AlertDialog.<init>(AlertDialog.java:63)
07-02 19:41:59.674: W/System.err(335):  at android.app.ProgressDialog.<init>(ProgressDialog.java:80)
07-02 19:41:59.674: W/System.err(335):  at android.app.ProgressDialog.<init>(ProgressDialog.java:76)
07-02 19:41:59.674: W/System.err(335):  at com.myproject.utils.Functions.getProgressDialog(Functions.java:54)
07-02 19:41:59.674: W/System.err(335):  at com.myproject.activities.MyDashboardActivity.onCreateDialog(MyDashboardActivity.java:178)
07-02 19:41:59.674: W/System.err(335):  at android.app.Activity.onCreateDialog(Activity.java:2482)
07-02 19:41:59.674: W/System.err(335):  at android.app.Activity.createDialog(Activity.java:882)
07-02 19:41:59.674: W/System.err(335):  at android.app.Activity.showDialog(Activity.java:2557)
07-02 19:41:59.674: W/System.err(335):  at android.app.Activity.showDialog(Activity.java:2524)
07-02 19:41:59.674: W/System.err(335):  at com.myproject.activities.MyDashboardActivity$FetchDashboardEntriesProcess.onPreExecute(MyDashboardActivity.java:211)
07-02 19:41:59.674: W/System.err(335):  at android.os.AsyncTask.execute(AsyncTask.java:391)
07-02 19:41:59.674: W/System.err(335):  at com.myproject.activities.MyDashboardActivity.onCreate(MyDashboardActivity.java:159)
07-02 19:41:59.674: W/System.err(335):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-02 19:41:59.684: W/System.err(335):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-02 19:41:59.684: W/System.err(335):  at android.app.ActivityThread.startActivityNow(ActivityThread.java:1487)
07-02 19:41:59.684: W/System.err(335):  at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
07-02 19:41:59.684: W/System.err(335):  at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
07-02 19:41:59.684: W/System.err(335):  at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
07-02 19:41:59.684: W/System.err(335):  at android.widget.TabHost.setCurrentTab(TabHost.java:326)
07-02 19:41:59.684: W/System.err(335):  at android.widget.TabHost.addTab(TabHost.java:216)
07-02 19:41:59.684: W/System.err(335):  at com.myproject.activities.IncludeTabActivity.onCreate(IncludeTabActivity.java:52)
07-02 19:41:59.684: W/System.err(335):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-02 19:41:59.684: W/System.err(335):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-02 19:41:59.684: W/System.err(335):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-02 19:41:59.694: W/System.err(335):  at  android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-02 19:41:59.694: W/System.err(335):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-02 19:41:59.694: W/System.err(335):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 19:41:59.694: W/System.err(335):  at android.os.Looper.loop(Looper.java:123)
07-02 19:41:59.694: W/System.err(335):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-02 19:41:59.694: W/System.err(335):  at  java.lang.reflect.Method.invokeNative(Native Method)
07-02 19:41:59.704: W/System.err(335):  at java.lang.reflect.Method.invoke(Method.java:507)
07-02 19:41:59.704: W/System.err(335):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-02 19:41:59.704: W/System.err(335):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-02 19:41:59.704: W/System.err(335):  at dalvik.system.NativeStart.main(Native Method)
  • 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-07T02:56:48+00:00Added an answer on June 7, 2026 at 2:56 am

    For me it looks like variable act is always null.

    Assing activity to act or try this:

    mProgressDialog = Functions.getProgressDialog(MyDashboardActivity.this,
                    getString(R.string.all_retriving_data));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want to construct a data frame in an Rcpp function, but when I
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.