title: Android WindowManager error : DispatchAttachedToWindow is not called
body: <p>My app interface as facebook chathead so i used overlay button. I used with intent service in my main activity. I create chathead ui in my FloatBitchService. UI create with WindowManager. Add float_view layout to WindowManager. In float_view layout, all of the controls are visible gone except butHead. butHead is overlay button. I want to show ovelay button click show other controls. I used with overlay button onTouchevent  for overlay button click. My Error occur in input textbox control. <strong>Debug Device is Samsung Galaxy Note 2.</strong>
  <br></p>
  
  <p><strong>Update</strong>
  <br>
  In Samsung Note 2 Android 4.3, after texting the input textbox pressed enter key show google search app. What wrong my app with google search app. 
  <br>
  <br><strong>(FloatBitchService.java)</strong></p>
  
  <pre><code>public class FloatBitchService extends Service {
  @Override
  public void onCreate() {
      windowManager = (WindowManager)getSystemService(WINDOW_SERVICE);
      LayoutInflater inflater = LayoutInflater.from(this);        
      viewFloat = inflater.inflate(R.layout.float_view, null);
      butHead = (Button)viewFloat.findViewById(R.id.butHead);
      ...........................
      parameters = new WindowManager.LayoutParams(
              WindowManager.LayoutParams.WRAP_CONTENT, // Width
              WindowManager.LayoutParams.WRAP_CONTENT, // Height
              WindowManager.LayoutParams.TYPE_PHONE, // Type
              WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,// Flag             
              PixelFormat.TRANSLUCENT // Format)
              );      
      parameters.x = 0;
      parameters.y = 0;
      parameters.gravity = Gravity.TOP | Gravity.LEFT;        
      windowManager.addView(viewFloat, parameters);
      butHead.setOnTouchListener(new OnTouchListener() {
  
          int initialX, initialY;
          float initialTouchX, initialTouchY;
  
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              // TODO Auto-generated method stub
  
              switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
  
                  // Get current time in nano seconds.
                  initialX = parameters.x;
                  initialY = parameters.y;
                  initialTouchX = event.getRawX();
                  initialTouchY = event.getRawY();
                  startClickTime = Calendar.getInstance().getTimeInMillis();
                  Toast.makeText(getApplication(), "Here to Remove", Toast.LENGTH_SHORT).show();
                  break;
              case MotionEvent.ACTION_UP:
                  // Check Single Click
                  long clickDuration = Calendar.getInstance().getTimeInMillis() - startClickTime;
                  if (clickDuration &lt; MAX_CLICK_DURATION){
                      if (layout1.getVisibility() == View.VISIBLE) {  
                          // isMove flag for chat head movement
                          isMove = true;
                          chatHeadClose();
                      }else {
                          // isMove flag for chat head movement
                          isMove = false;
                          chatHeadOpen();
                      }
                  }
  
                  Display display = windowManager.getDefaultDisplay();
                  Point point = new Point();
                  display.getSize(point);
                  screenWidth = point.x;
                  screenHeight = point.y;
  
                  // Dictionary Panel size set to fix screen size
                  LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)layout1.getLayoutParams();
                  params.width = screenWidth;
                  params.height = (int)(screenHeight * 0.68);
  
                  // Calculate for Delete Space [ * ]
                  int screenWidthHalf = screenWidth / 2;
                  int rightValue = screenWidthHalf + 100;
                  int leftValue = screenWidthHalf - 100;
                  int headwidth = butHead.getWidth() / 2;
  
                  // float item close when arrive screen bottom                   
                  if (parameters.y &gt; (screenHeight - 450) &amp;&amp; (parameters.x + headwidth) &gt; leftValue &amp;&amp; (parameters.x + headwidth) &lt; rightValue) {
                      viewFloat.setVisibility(View.GONE);
                      Toast.makeText(getApplication(), "Removed!",Toast.LENGTH_SHORT).show();
                      stopSelf();
                  }
                  break;
              case MotionEvent.ACTION_MOVE:
                  if (isMove) {
                      // chathead movement
                      parameters.x = initialX + (int) (event.getRawX() - initialTouchX);
                      parameters.y = initialY + (int) (event.getRawY() - initialTouchY);                      
                      windowManager.updateViewLayout(viewFloat, parameters);
                  }
                  break;
  
              }
  
              return false;
          }
      });
  }
  private void chatHeadOpen()
  {
      parameters = new WindowManager.LayoutParams(
              WindowManager.LayoutParams.WRAP_CONTENT, // Width
              WindowManager.LayoutParams.WRAP_CONTENT, // Height
              WindowManager.LayoutParams.TYPE_PHONE, // Type
              WindowManager.LayoutParams.FLAG_BLUR_BEHIND,// Flag             
              PixelFormat.TRANSLUCENT // Format)
              );
  
      parameters.x = 0;
      parameters.y = 0;
      parameters.gravity = Gravity.TOP | Gravity.LEFT;
      windowManager.removeView(viewFloat);
      windowManager.addView(viewFloat, parameters);                           
      layout1.setVisibility(View.VISIBLE);
  }
  
  private void chatHeadClose(){
      parameters = new WindowManager.LayoutParams(
              WindowManager.LayoutParams.WRAP_CONTENT, // Width
              WindowManager.LayoutParams.WRAP_CONTENT, // Height
              WindowManager.LayoutParams.TYPE_PHONE, // Type
              WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,// Flag             
              PixelFormat.TRANSLUCENT // Format)
              );
  
      parameters.x = 0;
      parameters.y = 0;
      parameters.gravity = Gravity.TOP | Gravity.LEFT;
      windowManager.removeView(viewFloat);
      windowManager.addView(viewFloat, parameters);
      layout1.setVisibility(View.GONE);
  }}
  </code></pre>
  
  <blockquote>
    <p><img src="https://i.stack.imgur.com/BFKWc.png" alt="Error Screen Shot"></p>
  </blockquote>