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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:57:23+00:00 2026-05-13T23:57:23+00:00

I am implementing a custom dialog to form an about screen with a simple

  • 0

I am implementing a custom dialog to form an about screen with a simple look and feel (which may become more complex once I get it working). I have a xml layout that loads some text and an icon from R. However when ever showDialog(int) is called I get a force close.

I followed the instructions as per the dev guide: http://developer.android.com/intl/de/guide/topics/ui/dialogs.html

code is as follows:

 @Override
 protected Dialog onCreateDialog(int id) {
   Dialog dialog;
      switch(id) {
      case DIAG_ABOUT:
       dialog = new Dialog(getApplicationContext());
       dialog.setContentView(R.layout.aboutdialog);
       dialog.setTitle(R.string.about_title);
       dialog.setOwnerActivity(this);
       break;
      default:
          dialog = null;
      }
      return dialog;
 }

DIAG_ABOUT is defined as private static final int DIAG_ABOUT = 0;

The Log cat shows the following trace:

03-04 11:37:08.760: ERROR/AndroidRuntime(726): Uncaught handler: thread main exiting due to uncaught exception
03-04 11:37:08.780: ERROR/AndroidRuntime(726): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.view.ViewRoot.setView(ViewRoot.java:429)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:178)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.app.Dialog.show(Dialog.java:231)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.app.Activity.showDialog(Activity.java:2407)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at uk.me.cpearson.runningLate.Home.onOptionsItemSelected(Home.java:143)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.app.Activity.onMenuItemSelected(Activity.java:2085)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:820)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:813)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:519)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.view.View.onTouchEvent(View.java:3828)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.widget.TextView.onTouchEvent(TextView.java:6291)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.view.View.dispatchTouchEvent(View.java:3368)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1691)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1525)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.os.Looper.loop(Looper.java:123)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at android.app.ActivityThread.main(ActivityThread.java:3948)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at java.lang.reflect.Method.invokeNative(Native Method)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at java.lang.reflect.Method.invoke(Method.java:521)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
03-04 11:37:08.780: ERROR/AndroidRuntime(726):     at dalvik.system.NativeStart.main(Native Method)

Can some one point out where I have gone wrong, I am using SDK 1.5

  • 1 1 Answer
  • 1 View
  • 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-05-13T23:57:23+00:00Added an answer on May 13, 2026 at 11:57 pm

    You need to use your Activty as the Context for the Dialog not the Application.

    Android is looking for a view to display the Dialog in and the Application does not have one but your Activity will. The Application is an object which ties your app together and has a Context as it knows about which locale you’re running in and so on, but it relies on Activities to display things to the user.

    Replace:

    dialog = new Dialog(getApplicationContext());
    

    with:

    dialog = new Dialog(this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 395k
  • Answers 395k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer After rebooting, the error was gone. I suspect just closing… May 15, 2026 at 2:45 am
  • Editorial Team
    Editorial Team added an answer apache ab might help, as can sql-bench. It is however… May 15, 2026 at 2:45 am
  • Editorial Team
    Editorial Team added an answer I would not say that your design, as you speculate,… May 15, 2026 at 2:45 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.