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

The Archive Base Latest Questions

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

I am trying to do the following: Create background service When a message is

  • 0

I am trying to do the following:

Create background service
When a message is received on the inputQueue from the MQTT broker
Show a popup

So I have the subscription to the mqtt broker working fine. When a message arrives – an intent is started to show the popup however the following error shows:


01-06 19:26:58.412: WARN/WindowManager(989): Failed looking up window
    01-06 19:26:58.412: WARN/WindowManager(989): java.lang.IllegalArgumentException:                        Requested window null does not exist
    01-06 19:26:58.412: WARN/WindowManager(989):     at    com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9408)
    01-06 19:26:58.412: WARN/WindowManager(989):     at com.android.server.WindowManagerService.addWindow(WindowManagerService.java:1934)
01-06 19:26:58.412: WARN/WindowManager(989):     at com.android.server.WindowManagerService$Session.add(WindowManagerService.java:6886)
01-06 19:26:58.412: WARN/WindowManager(989):     at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:66)
01-06 19:26:58.412: WARN/WindowManager(989):     at com.android.server.WindowManagerService$Session.onTransact(WindowManagerService.java:6858)
01-06 19:26:58.412: WARN/WindowManager(989):     at android.os.Binder.execTransact(Binder.java:288)
01-06 19:26:58.412: WARN/WindowManager(989):     at dalvik.system.NativeStart.run(Native Method)
01-06 19:26:58.412: DEBUG/AndroidRuntime(5364): Shutting down VM
01-06 19:26:58.412: WARN/dalvikvm(5364): threadid=1: thread exiting with uncaught exception (group=0x4001d878)
01-06 19:26:58.412: WARN/WindowManager(989): Attempted to add window with token that is not a window: null.  Aborting.
01-06 19:26:58.422: ERROR/AndroidRuntime(5364): FATAL EXCEPTION: main
01-06 19:26:58.422: ERROR/AndroidRuntime(5364): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.andy.tabletsms.tablet/com.andy.tabletsms.work.SMSPopup}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.os.Looper.loop(Looper.java:123)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.app.ActivityThread.main(ActivityThread.java:4627)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at java.lang.reflect.Method.invokeNative(Native Method)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at java.lang.reflect.Method.invoke(Method.java:521)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at dalvik.system.NativeStart.main(Native Method)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.view.ViewRoot.setView(ViewRoot.java:505)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.widget.PopupWindow.invokePopup(PopupWindow.java:828)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.widget.PopupWindow.showAtLocation(PopupWindow.java:688)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at com.andy.tabletsms.work.SMSPopup.onCreate(SMSPopup.java:58)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-06 19:26:58.422: ERROR/AndroidRuntime(5364):     ... 11 more
01-06 19:26:58.432: WARN/ActivityManager(989):   Force finishing activity com.andy.tabletsms.tablet/com.andy.tabletsms.work.SMSPopup
01-06 19:26:58.432: WARN/ActivityManager(989):   Force finishing activity com.andy.tabletsms.tablet/.main
01-06 19:26:58.932: WARN/ActivityManager(989): Activity pause timeout for HistoryRecord{444da2b8 com.andy.tabletsms.tablet/com.andy.tabletsms.work.SMSPopup}

The queue is checked every 5 seconds and issues a start activity for the popup if there is an item as follows


 SMSPopup.msg = main.msgs.get(0);
      Intent testActivityIntent = new Intent(context.getApplicationContext(), com.andy.tabletsms.work.SMSPopup.class);
  testActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  context.startActivity(testActivityIntent);

The SMSPopup class looks as follows:


package com.andy.tabletsms.work;


import com.andy.tabletsms.tablet.R;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.Toast;

public class SMSPopup extends Activity{

 public static String msg;
 private PopupWindow pw;

 @Override
 public void onCreate(Bundle bundle){
  super.onCreate(bundle);
  Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
  LayoutInflater inflater = LayoutInflater.from(this);
  // inflate our view from the corresponding XML file
  View layout = inflater.inflate(R.layout.popup, (ViewGroup)findViewById(R.id.popup_menu_root));
  // create a 100px width and 200px height popup window
  pw = new PopupWindow(layout, 100, 200, true);
  // set actions to buttons we have in our popup
  Button button1 = (Button)layout.findViewById(R.id.popup_menu_button1);
  button1.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View vv) {
          // close the popup
          pw.dismiss();
      }
  });
  Button button2 = (Button)layout.findViewById(R.id.popup_menu_button2);
  button2.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View vv) {
       Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
      }
  });
  Button button3 = (Button)layout.findViewById(R.id.popup_menu_button3);
  button3.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View vv) {
          finish();
      }
  });
  // finally show the popup in the center of the window


  pw.showAtLocation(layout, Gravity.CENTER, 0, 0);

 }
}

  • 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-05-19T01:57:24+00:00Added an answer on May 19, 2026 at 1:57 am

    Other posts have pointed out the issue of attempting to popup too early. However I also think you really shouldn’t be doing this:

    public static String msg;
    

    and

    SMSPopup.msg = main.msgs.get(0);
    

    This is not the right way to pass data to another Activity. You should be setting the data as an Extra on the Intent, like this:

    Intent testActivityIntent = new Intent(context.getApplicationContext(), com.andy.tabletsms.work.SMSPopup.class);
    testActivityIntent.putExtra("com.andy.tabletsms.message", main.msgs.get(0));
    testActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(testActivityIntent);
    

    You can then retrieve the message in your target Activity:

    private String msg;
    ...
    Intent intent = getIntent();
    if (intent != null){
        Bundle bundle = intent.getExtras();
        if (bundle != null){
            msg = bundle.getString("com.andy.tabletsms.message");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a UINavigationController with a background Image... I have the
Background I am trying to create a copy of a business object I have
I am trying to create a table with the following: CREATE TABLE GTW_WORKFLOW_MON (
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create a list to return some JSON data to a view. Following
I'm trying to create an algorithm in C# which produces the following output strings:
I am trying to create an expression tree that represents the following: myObject.childObjectCollection.Any(i =>
In MySQL 5.0 why does the following error occur when trying to create a
I'm trying to create the following. The problem is that the stuff in row1
I'm trying to create an accordion type menu using the following JQUERY: function initMenu()

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.