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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:16:54+00:00 2026-06-01T01:16:54+00:00

in my activity I originally used a handler to update the UI with data

  • 0

in my activity I originally used a handler to update the UI with data received from the internet. I now want to display this data inside an alertdialog instead of on the UI screen. The program works by pressing a button, gets the information and displays it on the screen. this is done by calling the necessary message for the handler. I managed to do for a Toast message and I thought the alertdialog would follow the same logic but I get the error:

RunTime Error: Unable to add Window -- token null is not for an application

Here is my code for the handler message, where the error is apparently caused (Line 84 which is the .show() method line):

Handler handler = new Handler()
{
    @Override
    public void handleMessage(Message msg) 
    {
        Context context = getApplicationContext();

        switch( msg.what )
        {
            case DISPLAY_TOAST:
                Toast t = Toast.makeText( context,"Toast Test",Toast.LENGTH_SHORT );
                t.show();       
            break;


            case UPDATE_UI: 
                htmlData.setText( feedback );           
            break;


            case DISPLAY_ALERT_DIALOG:

                passTime = new AlertDialog.Builder( context );
                passTime.setTitle( alertDialogTitleStrg );
                passTime.setMessage( alertDialogMsgStrg );
                passTime.show();

            break;
        }

    }
}; 
  • 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-01T01:16:55+00:00Added an answer on June 1, 2026 at 1:16 am

    Your context object is wrong, the simplest way you can do is the following:

    passTime = new AlertDialog.Builder( YourActivity.this );
    

    greetings

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

Sidebar

Related Questions

I launch an activity to capture a picture from camera: Intent i = new
What is this error, and why does it happen? 05-17 18:24:57.069: ERROR/WindowManager(18850): Activity com.mypkg.myP
These are the activity and Image Adapter that I used for my CoverFlow. But
So I have this JSON, which then my activity retrieves to a string: {popular:
I originally registered my broadcast receiver in my main Activity via code. However, I
I am trying to pass data through my Intent into the next activity so
Originally my AndroidManifest.xml contained an activity which I reached through its custom action name.
Originally, I had a MediaPlayer mPlayers to play/pause/stop my Audio file. Now, I'm trying
I want to implement some form of (GWT 2.1 MVP) pre-Activity checking that ensures
Friends, onCreate() I am loading data from webservice using Async thread. when thread is

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.