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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:34:20+00:00 2026-06-06T18:34:20+00:00

I’m writting an application which has to contact a webservice. It’s working. But, now

  • 0

I’m writting an application which has to contact a webservice.
It’s working.
But, now I have to use the async task. I have to fill a list of category.
I can’t figure what’s the problem.

The async class :

private class CallCategory extends AsyncTask<List<Category>,Void,List<Category>>{
        private ProgressDialog dialog;


        protected void onPreExecute() {
            this.dialog = ProgressDialog.show(getApplicationContext(), "Calling", "Time Service...", true);
        }

        protected void onPostExecute() {
            this.dialog.cancel();
        }

        @Override
        protected List<Category> doInBackground(List<Category>... params) {
            return ServerCall.GetCategory();
        }


    }

The call :

    CallCategory cc = new CallCategory();
    _ListCategory = new ArrayList<Category>();
    cc.execute();

GetCategory fonction :

public static List<Category> GetCategory (){
    List<Category> categories = null;
    try{

        String url =  "http://188.130.40.103/api/"+"Category";
        RestClient client = new RestClient(url);

        //Call
        client.Execute(RequestMethod.GET);

        if(client.getResponseCode() == 200){

        //Get the response
        String response = client.getResponse();

        //build list of categories
        Type listType = new TypeToken<ArrayList<Category>>() {
    }.getType();

     categories = new Gson().fromJson(response, listType);
    }

    }
    catch (Exception e) {
        Log.i("Error", e.toString());
    }
    return categories;
}

StackTrace :

 06-29 12:58:57.746: W/dalvikvm(3087): threadid=3: thread exiting with
     uncaught exception (group=0x4001b188) 06-29 12:58:57.746:
     E/AndroidRuntime(3087): Uncaught handler: thread main exiting due to
     uncaught exception 06-29 12:58:57.786: E/AndroidRuntime(3087):
     java.lang.RuntimeException: Unable to start activity
     ComponentInfo{ApPicture.Android/ApPicture.Android.ApPictureActivity}:
     android.view.WindowManager$BadTokenException: Unable to add window --
     token null is not for an application 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.ActivityThread.access$2200(ActivityThread.java:119) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.os.Handler.dispatchMessage(Handler.java:99) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     android.os.Looper.loop(Looper.java:123) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.app.ActivityThread.main(ActivityThread.java:4363) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     java.lang.reflect.Method.invokeNative(Native Method) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     java.lang.reflect.Method.invoke(Method.java:521) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     dalvik.system.NativeStart.main(Native Method) 06-29 12:58:57.786:
     E/AndroidRuntime(3087): Caused by:
     android.view.WindowManager$BadTokenException: Unable to add window --
     token null is not for an application 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.view.ViewRoot.setView(ViewRoot.java:472) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.Dialog.show(Dialog.java:239) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.app.ProgressDialog.show(ProgressDialog.java:107) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     android.app.ProgressDialog.show(ProgressDialog.java:90) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     ApPicture.Android.ApPictureActivity$CallCategory.onPreExecute(ApPictureActivity.java:406)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.os.AsyncTask.execute(AsyncTask.java:391) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     ApPicture.Android.ApPictureActivity.LoadCategory(ApPictureActivity.java:291)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     ApPicture.Android.ApPictureActivity.onCreate(ApPictureActivity.java:108)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    ... 11 more

Regards.

  • 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-06T18:34:22+00:00Added an answer on June 6, 2026 at 6:34 pm

    Change yours with this

    this.dialog = ProgressDialog.show(YourActivity.this, "Calling", "Time Service...", true);
    

    And second, you can’t call show() method in onPreExecute. I recommend to you to show your Dialog before you execute a task.

    ...
    dialog.show();
    task.execute();
    ...
    

    Unable to add window

    This error usually cause getApplicationContext().

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

Sidebar

Related Questions

I have an array which has BIG numbers and small numbers in it. I
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms

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.