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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:02:39+00:00 2026-06-18T01:02:39+00:00

For a Android programming class i am trying to impliment a QuickAction Activity, but

  • 0

For a Android programming class i am trying to impliment a QuickAction Activity, but I can’t get it to load in my program. This is the code that I think is failing on load.

    import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class MainActivity extends Activity
{

    @Override

    protected void onCreate(Bundle savedInstanceState)
    {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //show on iBtn1
        ImageButton iBtn1 = (ImageButton) this.findViewById(R.id.iBtn1);
        iBtn1.setOnClickListener(new View.OnClickListener()
        {



            @Override
            public void onClick(View v)
            {

                startActivity(new Intent(getApplicationContext(),
                        QuickActionBar.class));
            }

        });


        final QuickActionIcons edit = new QuickActionIcons();;

        edit.setTitle("Edit");
        edit.setIcon(getResources().getDrawable(R.drawable.edit));

        edit.setOnClickListener(new OnClickListener()
        {

            public void onClick(View v)
            {
                Toast.makeText(MainActivity.this,"Edit Contact",Toast.LENGTH_SHORT).show();
            }

        });

        final QuickActionIcons call = new QuickActionIcons();;

        call.setTitle("Call");
        call.setIcon(getResources().getDrawable(R.drawable.call));

        call.setOnClickListener(new OnClickListener()
        {

            public void onClick(View v)
            {
                Toast.makeText(MainActivity.this,"Call Contact",Toast.LENGTH_SHORT).show();
            }

        });

        final QuickActionIcons call3 = new QuickActionIcons();;

        call3.setTitle("Call3");
        call3.setIcon(getResources().getDrawable(R.drawable.call));

        call3.setOnClickListener(new OnClickListener()
        {

            public void onClick(View v)
            {
                // Toast.makeText(QuickActionSampleAppActivity.this,"Call Contact",Toast.LENGTH_SHORT).show();
            }

        });

        final QuickActionIcons call1 = new QuickActionIcons();;

        call1.setTitle("Call 1");      
        call1.setIcon(getResources().getDrawable(R.drawable.call));

        call1.setOnClickListener(new OnClickListener()
        {

            public void onClick(View v)
            {
                // Toast.makeText(QuickActionSampleAppActivity.this,"Call Contact",Toast.LENGTH_SHORT).show();
            }

        });

        final QuickActionIcons call2 = new QuickActionIcons();;

        call2.setTitle("Call 2");       
        call2.setIcon(getResources().getDrawable(R.drawable.call));

        call2.setOnClickListener(new OnClickListener()
        {

            public void onClick(View v)
            {
                // Toast.makeText(QuickActionSampleAppActivity.this,"Call Contact",Toast.LENGTH_SHORT).show();
            }

        });

        final QuickActionIcons send_data = new QuickActionIcons();;

        send_data.setTitle("Send Data");      
        send_data.setIcon(getResources().getDrawable(R.drawable.bluetooth));

        send_data.setOnClickListener(new OnClickListener()
        {

            public void onClick(View v)
            {
                //  Toast.makeText(QuickActionSampleAppActivity.this,"Start Transfer of Data",Toast.LENGTH_SHORT).show();
            }

        });

        QuickActionBar qab = new QuickActionBar(iBtn1);
        qab.addItem(edit);
        qab.addItem(call);
        qab.addItem(send_data);
        qab.addItem(call1);
        qab.addItem(call2);
        qab.addItem(call3);
        qab.setAnimationStyle(QuickActionBar.GROW_FROM_LEFT);
        qab.show();


    }

    @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_main, menu);
        return true;
    }
}

Here is my LogCat

    01-30 17:16:39.650: E/Trace(810): error opening trace file: No such file or directory (2)
    01-30 17:16:39.650: W/Trace(810): Unexpected value from nativeGetEnabledTags: 0
    01-30 17:16:39.650: W/Trace(810): Unexpected value from nativeGetEnabledTags: 0
    01-30 17:16:39.650: W/Trace(810): Unexpected value from nativeGetEnabledTags: 0
    01-30 17:16:40.038: W/Trace(810): Unexpected value from nativeGetEnabledTags: 0
    01-30 17:16:40.038: W/Trace(810): Unexpected value from nativeGetEnabledTags: 0
    01-30 17:16:41.618: D/dalvikvm(810): GC_CONCURRENT freed 67K, 7% free 2811K/3000K, paused 18ms+5ms, total 90ms
    01-30 17:16:41.618: D/dalvikvm(810): WAIT_FOR_CONCURRENT_GC blocked 56ms
    01-30 17:16:41.638: I/dalvikvm-heap(810): Grow heap (frag case) to 3.933MB for 1127536-byte allocation
    01-30 17:16:41.718: D/dalvikvm(810): GC_FOR_ALLOC freed 3K, 5% free 3909K/4104K, paused 74ms, total 75ms
    01-30 17:16:41.838: D/dalvikvm(810): GC_CONCURRENT freed <1K, 5% free 4098K/4296K, paused 9ms+20ms, total 124ms
    01-30 17:16:42.058: D/AndroidRuntime(810): Shutting down VM
    01-30 17:16:42.058: W/dalvikvm(810): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
    01-30 17:16:42.108: E/AndroidRuntime(810): FATAL EXCEPTION: main
    01-30 17:16:42.108: E/AndroidRuntime(810): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.rasmussen.mobile/edu.rasmussen.mobile.MainActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.os.Handler.dispatchMessage(Handler.java:99)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.os.Looper.loop(Looper.java:137)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.app.ActivityThread.main(ActivityThread.java:5039)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at java.lang.reflect.Method.invokeNative(Native Method)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at java.lang.reflect.Method.invoke(Method.java:511)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at dalvik.system.NativeStart.main(Native Method)
    01-30 17:16:42.108: E/AndroidRuntime(810): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.view.ViewRootImpl.setView(ViewRootImpl.java:567)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:246)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.widget.PopupWindow.invokePopup(PopupWindow.java:993)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.widget.PopupWindow.showAtLocation(PopupWindow.java:847)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.widget.PopupWindow.showAtLocation(PopupWindow.java:811)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at edu.rasmussen.mobile.QuickActionBar.show(QuickActionBar.java:120)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at edu.rasmussen.mobile.MainActivity.onCreate(MainActivity.java:141)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.app.Activity.performCreate(Activity.java:5104)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    01-30 17:16:42.108: E/AndroidRuntime(810):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
    01-30 17:16:42.108: E/AndroidRuntime(810):  ... 11 more

Here are the Console
[2013-01-30 11:13:08 - GeoTag] ------------------------------
[2013-01-30 11:13:08 - GeoTag] Android Launch!
[2013-01-30 11:13:08 - GeoTag] adb is running normally.
[2013-01-30 11:13:08 - GeoTag] Performing edu.rasmussen.mobile.MainActivity activity launch
[2013-01-30 11:13:08 - GeoTag] Automatic Target Mode: launching new emulator with compatible AVD 'Galaxy'
[2013-01-30 11:13:08 - GeoTag] Launching a new emulator with Virtual Device 'Galaxy'
[2013-01-30 11:13:13 - GeoTag] New emulator found: emulator-5554
[2013-01-30 11:13:13 - GeoTag] Waiting for HOME ('android.process.acore') to be launched...
[2013-01-30 11:14:50 - GeoTag] HOME is up on device 'emulator-5554'
[2013-01-30 11:14:50 - GeoTag] Uploading GeoTag.apk onto device 'emulator-5554'
[2013-01-30 11:14:50 - GeoTag] Installing GeoTag.apk...
[2013-01-30 11:16:28 - GeoTag] Success!
[2013-01-30 11:16:28 - GeoTag] Starting activity edu.rasmussen.mobile.MainActivity on device emulator-5554
[2013-01-30 11:16:31 - GeoTag] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=edu.rasmussen.mobile/.MainActivity }

Stacktrace

GeoTag [Android Application]    
    DalvikVM[localhost:8789]    
        Thread [<1> main] (Running) 
        Thread [<10> Binder_2] (Running)    
        Thread [<9> Binder_1] (Running) 
  • 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-18T01:02:41+00:00Added an answer on June 18, 2026 at 1:02 am

    The exception message:

    Unable to add window — token null is not valid; is your activity running?

    You are trying to add a window on top of your activity when your activity isn’t ready to process this (the window of the activity isn’t shown yet). There are numerous ways of the dealing with this. One solution could be using a post-runnable, so the action will delayed.

    view.post(new Runnable() {
       public void run() {
          // show your quick action here
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying out some android programming that has gone fine up until this point. I'm
I am trying to get into Android programming, but I cannot understand the Google
I am new to android programming and i am trying to develop this app
I'm new in Android Programming. I'm trying to write an app that uses USB
I am trying to use java.awt.polygon class in android programming. In Java build paths,
Hi I'm new to Android Programming and I'm trying to make a simple program
I am trying to get GPS data without using map view.The code that I
I've been trying to get started with Android programming for a while now. I'm
I am new to android programming and trying to use webservice in this sample
I'm trying to work through this book on android programming and one of the

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.