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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:26:38+00:00 2026-06-14T21:26:38+00:00

I have application which is connected with webservice. When I start application I call

  • 0

I have application which is connected with webservice.
When I start application I call class:

public class CaApplication extends Application {

    @Override
    public void onCreate() {
        // TODO Auto-generated method stub
        super.onCreate();
        DataRetrieve dr ;
        ProgressDialog progressBar;

            progressBar = new ProgressDialog(this);

            //progress bar orientation
            progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

            // Text that will appear on the progress bar dialog
            progressBar.setMessage("Loading...");

        //set whether the progress bar is cancelable or not
            progressBar.setCancelable(false);
            progressBar.show();
         dr = new DataRetrieve();
    }
}

I get Error:

11-25 15:39:36.698: E/AndroidRuntime(30429): Caused by: 11-25 15:39:36.698: E/AndroidRuntime(30429): java.lang.RuntimeException: Unable to create application com.example.storeclientdropdown.CambiumApplication: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3974)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.app.ActivityThread.access$1300(ActivityThread.java:127)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.os.Looper.loop(Looper.java:137)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.app.ActivityThread.main(ActivityThread.java:4441)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at java.lang.reflect.Method.invokeNative(Native Method)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at java.lang.reflect.Method.invoke(Method.java:511)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at dalvik.system.NativeStart.main(Native Method)
11-25 15:39:36.698: E/AndroidRuntime(30429): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.view.ViewRootImpl.setView(ViewRootImpl.java:517)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:301)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.app.Dialog.show(Dialog.java:278)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at com.example.storeclientdropdown.CambiumApplication.onCreate(CambiumApplication.java:35)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
11-25 15:39:36.698: E/AndroidRuntime(30429):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3971)
11-25 15:39:36.698: E/AndroidRuntime(30429):    ... 10 more

In DataRetrive I get all data from webservice and after that I call MainActivity.
What is wrong and how I can fix this bug. I try: progressBar = new ProgressDialog(this);, progressBar = new ProgressDialog(getApplicationContext());, progressBar = new ProgressDialog(getBaseContext); but no result.

  • 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-14T21:26:39+00:00Added an answer on June 14, 2026 at 9:26 pm

    Application is NOT Context, you cannot use it as a base for a Dialog.

    what you should do is in the MainActivity (meaning the first activity that runs) is to start the ProgressBar instead of doing this in the Application level.

    try reading some of the great documentation in the developers site

    EDIT:

    from what I understand, you are trying to create a splash screen that will do work before the actual app starts.

    this is a very simple thing to do and should be done like this:

    public class SplashScreen extends Activity {
        @Override
        public void onCreate() {
            super.onCreate();
            DataRetrieve dr ;
            ProgressDialog progressBar;
    
            progressBar = new ProgressDialog(this);
    
            //progress bar orientation
            progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    
            // Text that will appear on the progress bar dialog
            progressBar.setMessage("Loading...");
    
           //set whether the progress bar is cancelable or not
            progressBar.setCancelable(false);
            progressBar.show();
            dr = new DataRetrieve(); // THIS SHOULD BE DONE IN AN AsyncTask
            // WHEN DATA IS DONE RETRIEVING
            progressBar.dismiss();
            Intent startApp = new Intent(SplashScreen.this, MainActivity.class);
            startActivity(startApp);
            finish();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which logs in into a webservice. I start a new
I have to develop a application (Winforms-application) which is connected to a database within
in my zf application i have base model class Application_Model, which connects to db
Please help!!! I have an ClickOnce Application which connects to a WebService to get
I have a WPF Window which calls a class library connected to a WCF
I have an application which tells the state of the device (Connected/Disconnected). Now I
i have created a application in VB6.0 which is connected to MySQL through ODBC
I have a Flex 4 application which connects to ASP.NET webservice based on FluorineFx
I have a system which contains multiple applications connected together using JMS and Spring
I have a WPF application which connects to a remote database over internet and

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.