/** Make the background visible on the given Window. */
 public void attach(Window window) {
   if (USE_SEPARATE_WINDOW) {
     attachBehindWindow(window);
   } else {
     attachToView(window.getDecorView());
   }
 }
  private void attachBehindWindow(Window window) {
    if (DEBUG) Log.v(TAG, "attachBehindWindow " + window);
    mWindow = window;
    mWindowManager = window.getWindowManager();

    WindowManager.LayoutParams params =
        new WindowManager.LayoutParams(
            // Media window sits behind the main application window
            WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA,
            // Avoid default to software format RGBA
            WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
            android.graphics.PixelFormat.TRANSLUCENT);
    params.setTitle(WINDOW_NAME);
    params.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;

    View backgroundView =
        LayoutInflater.from(mContext).inflate(R.layout.lb_background_window, null);
    mWindowManager.addView(backgroundView, params);

    attachToView(backgroundView);
  }