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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:33:17+00:00 2026-06-18T05:33:17+00:00

In my app, I am fetching data from web server. I have used async

  • 0

In my app, I am fetching data from web server. I have used async task for fetching data. But, problem is sometimes my app crashes in onPostExecute on progressDialog.dismiss(). But, this does not happens everytime. Here is my code:

Async Task

public class GetFeaturedStoreListAsyncTask extends AsyncTask<Void, Void, String>
{
Context ctx;
ProgressDialog pd;
ListView listFeaturedStore;
String dataUrl;
public static final String TAG = "GetFeaturedStoreAsyncTask";
public static ArrayList<StoreDescriptionDAO> featuredDAOList;

public GetFeaturedStoreListAsyncTask(String dataUrl, Context ctx, ListView listFeaturedStore) 
{
    this.dataUrl = dataUrl;
    this.ctx = ctx;
    this.listFeaturedStore = listFeaturedStore;
}//Constructor

@Override
protected void onPreExecute() 
{
    pd = new ProgressDialog(ctx);
    pd.setMessage(ctx.getResources().getString(R.string.please_wait));
    pd.show();
}//onPreExecute

@Override
protected String doInBackground(Void... params) 
{   
    Log.v(TAG, "doInBackground called");
    JSONParser jsonParser = new JSONParser();
    String serverResponse = jsonParser.getJsonString(dataUrl);
    return serverResponse;
}//doInBackground

@Override
protected void onPostExecute(String response) 
{
    FeaturedListAdapter mFeaturedListAdapter = null;
    mFeaturedListAdapter = getFeaturedListAdapter(response);

    if(mFeaturedListAdapter != null)
    {
        Log.v(TAG, "adapter not null");
        listFeaturedStore.setAdapter(mFeaturedListAdapter);
        listFeaturedStore.setLayoutAnimation(AnimationUtility.fastCascadeListViewAnimation());
        pd.dismiss();
    }//if
    else
    {
        Log.v(TAG, "adapter null");
        pd.dismiss();
        SeattleNightLifeUtility.OpenUtilityDialog(ctx, 
                ctx.getResources().getString(R.string.network_error_msg));
    }//else
}//onPostExecute

private FeaturedListAdapter getFeaturedListAdapter(String jString) 
{
    FeaturedListAdapter mFeaturedAdapter = null;
    featuredDAOList = 
            ParsedFeaturedStoreDescData.getFeaturedStoreDesc(jString);
    if(featuredDAOList != null 
            && featuredDAOList.size() > 0)
    {
        mFeaturedAdapter = new FeaturedListAdapter(ctx, featuredDAOList);
        Log.v(TAG, "arraylist size > 0");
        return mFeaturedAdapter;
    }//if
    else
    {
        return null;
    }//else
}//getFeaturedListAdapter
}//GetCityStoreAsyncTask

Here is my logcat:

Activity com.dzo.seattlesnightlife.FeaturedActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4a715c38 that was originally added here
02-02 15:23:45.426: E/WindowManager(12627): android.view.WindowLeaked: Activity com.dzo.seattlesnightlife.FeaturedActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4a715c38 that was originally added here
02-02 15:23:45.426: E/WindowManager(12627):     at android.view.ViewRoot.<init>(ViewRoot.java:247)
02-02 15:23:45.426: E/WindowManager(12627):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
02-02 15:23:45.426: E/WindowManager(12627):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
02-02 15:23:45.426: E/WindowManager(12627):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
02-02 15:23:45.426: E/WindowManager(12627):     at android.app.Dialog.show(Dialog.java:241)
02-02 15:23:45.426: E/WindowManager(12627):     at com.dzo.seattlesnightlife.asynctask.GetFeaturedStoreListAsyncTask.onPreExecute(GetFeaturedStoreListAsyncTask.java:40)
02-02 15:23:45.426: E/WindowManager(12627):     at android.os.AsyncTask.execute(AsyncTask.java:391)
02-02 15:23:45.426: E/WindowManager(12627):     at com.dzo.seattlesnightlife.FeaturedActivity$MyTimerTask$1.run(FeaturedActivity.java:173)
02-02 15:23:45.426: E/WindowManager(12627):     at android.os.Handler.handleCallback(Handler.java:587)
02-02 15:23:45.426: E/WindowManager(12627):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-02 15:23:45.426: E/WindowManager(12627):     at android.os.Looper.loop(Looper.java:123)
02-02 15:23:45.426: E/WindowManager(12627):     at android.app.ActivityThread.main(ActivityThread.java:4633)
02-02 15:23:45.426: E/WindowManager(12627):     at java.lang.reflect.Method.invokeNative(Native Method)
02-02 15:23:45.426: E/WindowManager(12627):     at java.lang.reflect.Method.invoke(Method.java:521)
02-02 15:23:45.426: E/WindowManager(12627):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
02-02 15:23:45.426: E/WindowManager(12627):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-02 15:23:45.426: E/WindowManager(12627):     at dalvik.system.NativeStart.main(Native Method)
02-02 15:23:45.456: V/GetFeaturedStoreAsyncTask(12627): arraylist size > 0
02-02 15:23:45.456: V/GetFeaturedStoreAsyncTask(12627): adapter not null
02-02 15:23:45.526: W/dalvikvm(12627): threadid=1: thread exiting with uncaught exception (group=0x400207d8)
02-02 15:23:45.536: E/AndroidRuntime(12627): FATAL EXCEPTION: main
02-02 15:23:45.536: E/AndroidRuntime(12627): java.lang.IllegalArgumentException: View not attached to window manager
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:355)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.view.Window$LocalWindowManager.removeView(Window.java:432)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.app.Dialog.dismissDialog(Dialog.java:278)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at  android.app.Dialog.access$000(Dialog.java:71)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.app.Dialog$1.run(Dialog.java:111)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.app.Dialog.dismiss(Dialog.java:268)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at com.dzo.seattlesnightlife.asynctask.GetFeaturedStoreListAsyncTask.onPostExecute(GetFeaturedStoreListAsyncTask.java:63)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at com.dzo.seattlesnightlife.asynctask.GetFeaturedStoreListAsyncTask.onPostExecute(GetFeaturedStoreListAsyncTask.java:1)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.os.AsyncTask.finish(AsyncTask.java:417)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.os.AsyncTask.access$300(AsyncTask.java:127)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.os.Looper.loop(Looper.java:123)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at android.app.ActivityThread.main(ActivityThread.java:4633)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at java.lang.reflect.Method.invokeNative(Native Method)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at java.lang.reflect.Method.invoke(Method.java:521)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-02 15:23:45.536: E/AndroidRuntime(12627):    at dalvik.system.NativeStart.main(Native Method)
02-02 15:23:45.556: W/ActivityManager(180):   Force finishing activity com.dzo.seattlesnightlife/.FeaturedActivity
  • 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-18T05:33:19+00:00Added an answer on June 18, 2026 at 5:33 am

    This problem arises when trying to show a ProgressDialog after you’ve exited an Activity.

    I just solved this problem Try this way:

    if ((this.mDialog != null) && this.mDialog.isShowing()) {
        this.mDialog.dismiss();
        this.mDialog = null;
     }
    

    in your overridden onDestroy() or onStop() methods.

    EDIT : You can create interface, pass it to AsyncTask (in constructor), and then call method in onPostExecute.

    For example:

    Your interface:

    public interface OnTaskCompleted {
        void onTaskCompleted();
    }
    

    Your Activity:

    public YourActivity implements OnTaskCompleted {
        //your Activity
    }
    

    And your AsyncTask:

    public YourTask extends AsyncTask<Object,Object,Object> { //change Object to required type
        private OnTaskCompleted listener;
    
        public YourTask(OnTaskCompleted listener) {
            this.listener=listener;
        }
    
    //required methods
    
        protected void onPostExecute(Object o) {
            //your stuff
            listener.onTaskCompleted();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an App using UITableViews and fetching data from a server. I am
I have a strange, but definitely serious problem regarding fetching data from some Facebook
I have designed a web service application and fetch app's data from my server
I have created a class for fetching server-side data in my iOS-App, based on
I have an annoying problem: I'm fetching a lot of GeoJSON data from a
My app uses data from a web server. On a website you can get
I have created ListView fetching data from app db, and it's working fine, when
I have an ASP.NET MVC 3 (.NET 4) web application. This app fetches data
Hi i have tried so much to open custom app from url, but i
I have added bundled products by fetching data from the CSV. Products added in

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.