title: Creating PopupWindow from IME: BadTokenException
body: <p>I'm trying to make a popup window appear from an IME service (an onscreen keyboard) that has no activity.  When I call popUp.showAtLocation(layout, Gravity.CENTER, 0, -100) I get a "Windowmanager$BadTokenException: Unable to add window -- token null is not valid."  I know it's a little unusual to open a popup window from a service with no associated activity -- is it possible?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public void initiatePopupWindow()
  {
      try {
  
          LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View layout = inflater.inflate(R.layout.popup_layout,null);
  
          // create a 300px width and 470px height PopupWindow
          popUp = new PopupWindow(layout, 300, 470, true);
          popUp.showAtLocation(layout, Gravity.CENTER, 0, -100);
  
  
          Button cancelButton = (Button) layout.findViewById(R.id.popup_cancel_button);
          cancelButton.setOnClickListener(inputView.cancel_button_click_listener);
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Any help would be appreciated.  Thank you</p>