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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:44:30+00:00 2026-06-16T00:44:30+00:00

I got BadTokenException error when I create a ProgressDialog in my application. I tried

  • 0

I got BadTokenException error when I create a ProgressDialog in my application. I tried read a few post regarding about the issue, I still can’t really get what’s the cause of it. I call the dialog function after I click on a button.

    protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_LOADING:
        dialog = new Dialog(this, android.R.style.Theme_Translucent);          
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.loading);
        break;


    default:
        dialog = null;
        break;
    }
    return dialog;  
};

The above code is my progress dialog code. I call it with just this showDialog(DIALOG_LOADING); Can anyone kindly tell me what causes this and how to overcome the issue? Any comments will be appreciated.

12-18 12:12:39.250: E/AndroidRuntime(7654): FATAL EXCEPTION: main
12-18 12:12:39.250: E/AndroidRuntime(7654): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4057a200 is not valid; is your activity running?
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.view.ViewRoot.setView(ViewRoot.java:532)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:200)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:114)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.app.Dialog.show(Dialog.java:241)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at   android.app.Activity.showDialog(Activity.java:2566)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.app.Activity.showDialog(Activity.java:2524)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at com.fl.wbillboard.Web_Input$1.onClick(Web_Input.java:128)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.view.View.performClick(View.java:2538)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.view.View$PerformClick.run(View.java:9152)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.os.Handler.handleCallback(Handler.java:587)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.os.Looper.loop(Looper.java:130)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at android.app.ActivityThread.main(ActivityThread.java:3687)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at java.lang.reflect.Method.invokeNative(Native Method)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at java.lang.reflect.Method.invoke(Method.java:507)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
12-18 12:12:39.250: E/AndroidRuntime(7654):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
12-18 12:12:39.250: E/AndroidRuntime(7654):     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-16T00:44:31+00:00Added an answer on June 16, 2026 at 12:44 am

    You have to use activity’s reffrence for show dialog..

    use this new Dialog(activity_name.this, android.R.style.Theme_Translucent); instead of new Dialog(this, android.R.style.Theme_Translucent);

    case DIALOG_LOADING:
            dialog = new Dialog(activity.this, android.R.style.Theme_Translucent);          
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.loading);
            break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got an application wich read some infos in a specific XML file. I would
Got this error message while trying to load view: The model item passed into
Got a seg fault from my memcpy that gdb can't give me anything else
got a problem, can't get my head around this jquery and would appreciate your
Got this error while trying to get the variables out of a class. Using
got a strange issue for you. I created a control that inserts a record
Got this error today while trying to build a project with checkstyle. This works
Got a company logo need to use on several worksheets. How can I use
got a decent setup working with jwplayer and the playlists. One thing i can't
Got a small question that ruins my day. I've got the Grails application that

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.