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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:04:24+00:00 2026-06-19T01:04:24+00:00

Please have a look at the following code The code used to create the

  • 0

Please have a look at the following code

The code used to create the Custom Dialog. This class is an action class for an AlertDialog. When the user clicks on “Yes” button on that AlertDialog, this class get fired.
private class PositiveDialogBtnAction implements DialogInterface.OnClickListener
{

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            // TODO Auto-generated method stub
            //Toast.makeText(getApplicationContext(), databaseConnector.getStreetAddress(selectedBranch), Toast.LENGTH_LONG).show();

            Dialog dialog = new Dialog(getApplicationContext());
            dialog.setContentView(R.layout.activity_call_dialog);
            dialog.setTitle("Select a Phone Number");

            dialog.show();
        }

    }

activity_call_dialog.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".CallDialog" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />

</RelativeLayout>

CallDialog.java

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class CallDialog extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_call_dialog);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_call_dialog, menu);
        return true;
    }

}

When I try to run the Custom Dialog, I get the following error

02-15 11:04:02.170: E/AndroidRuntime(585): FATAL EXCEPTION: main
02-15 11:04:02.170: E/AndroidRuntime(585): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
02-15 11:04:02.170: E/AndroidRuntime(585):  at android.view.ViewRoot.setView(ViewRoot.java:531)
02-15 11:04:02.170: E/AndroidRuntime(585):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
02-15 11:04:02.170: E/AndroidRuntime(585):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
02-15 11:04:02.170: E/AndroidRuntime(585):  at android.app.Dialog.show(Dialog.java:241)
02-15 11:04:02.170: E/AndroidRuntime(585):  at com.example.esoftcallmanager.Form$PositiveDialogBtnAction.onClick(Form.java:155)
02-15 11:04:02.170: E/AndroidRuntime(585):  at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
02-15 11:04:02.170: E/AndroidRuntime(585):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-15 11:04:02.170: E/AndroidRuntime(585):  at android.os.Looper.loop(Looper.java:123)
02-15 11:04:02.170: E/AndroidRuntime(585):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-15 11:04:02.170: E/AndroidRuntime(585):  at java.lang.reflect.Method.invokeNative(Native Method)
02-15 11:04:02.170: E/AndroidRuntime(585):  at java.lang.reflect.Method.invoke(Method.java:507)
02-15 11:04:02.170: E/AndroidRuntime(585):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-15 11:04:02.170: E/AndroidRuntime(585):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-15 11:04:02.170: E/AndroidRuntime(585):  at dalvik.system.NativeStart.main(Native Method)
02-15 11:04:05.520: I/Process(585): Sending signal. PID: 585 SIG: 9

Why is this? Please help!

  • 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-19T01:04:25+00:00Added an answer on June 19, 2026 at 1:04 am

    use

    Dialog dialog = new Dialog(CallDialog.this);
    

    instead of

    Dialog dialog = new Dialog(getApplicationContext());
    

    because for showing Dialog you will need to pass Activity Context instead of Application

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

Sidebar

Related Questions

please have a look at the following code import java.util.ArrayList; import java.util.List; public class
Please have a look at the following code namespace Funny { class QuesionsAndAnswers {
Please have a look at the following code: $(#saveButton).click(function(){ $this = $(#tableData).find(input:checked).parent().parent(); tea =
Please have a look at the following machine code ‎0111001101110100011100100110010101110011011100110110010101100100 This means something. I
Please have a look at following code : import java.util.ArrayList; import java.util.List; class Main{
Please have a look at the following code template <typename T> class Stack {
Please have a look at the following code DatabaseHandler.java The code used to retrieve
Please have a look at the following java code import java.util.Scanner; public class Main
Please have look at the following code VehicleManager.h #pragma once #include Vehicle.h class VehicleManager
Please have a look at the following code Calculator.h #pragma once #include <iostream> template<class

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.