title: Lose focus when hiding system bar
body: <p>I'm using an webview that is displayed on top of the lock screen, also I'm automatically hiding the system bar after a short period of time:</p>
  
  <pre><code>/**
   * Class used to hide the device System UI bar.
   * 
   */
  public class SystemUiHider {
      /**
       * Delay until to hide the bar.
       */
      private static final int HIDE_DELAY_MILLIS = 3000;
  
      /**
       * Declare the handler.
       */
      private Handler mHandler;
      /**
       * Declare the view on which to hide the bar.
       */
      private View mView;
  
      private Utils utils;
  
      /**
       * Set the class view to be used.
       * 
       * @param view
       */
      public SystemUiHider(final View view, final Context context) {
          this.mView = view;
          this.utils = new Utils(context);
  
      }
  
      /**
       * Setup used to hide the system bar and start the handler.
       */
      public final void setup() {
          hideSystemUi();
          this.mHandler = new Handler();
          mView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
              @Override
              public void onSystemUiVisibilityChange(final int visibility) {
                  if (visibility != View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) {
                      delay();
                  }
              }
          });
      }
  
      /**
       * Set the flag to hidden for the view.
       */
      private void hideSystemUi() {
          utils.hideSystemBar(WebViewActivity.appContext);
      }
  
      /**
       * Set the runnable that runs on a different thread to call the method
       * hiding the system bar.
       */
      private Runnable mHideRunnable = new Runnable() {
          public void run() {
              hideSystemUi();
          }
      };
  
      /**
       * Set the delay until to hide the system bar.
       */
      private void delay() {
          mHandler.removeCallbacks(mHideRunnable);
          mHandler.postDelayed(mHideRunnable, HIDE_DELAY_MILLIS);
      }
  }
  </code></pre>
  
  <p>And this is the method that hides the system bar:</p>
  
  <pre><code>/**
   * Hide system bar.
   * Different methods applied depending on the SDK version
   *
   * @param context
   */
  @SuppressLint("InlinedApi")
  @SuppressWarnings("deprecation")
  public void hideSystemBar(Context context) {
      if (SDK_INT &lt; FOURTEEN) {
          Log.i("WebViewClient", "hideSystemBar: &lt; 14 ");
          ((Activity) context).getWindow().getDecorView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
      } else if (SDK_INT &gt;= FOURTEEN &amp;&amp; SDK_INT &lt; SIXTEEN) {
          Log.i("WebViewClient", "hideSystemBar: 14  - 16");
          ((Activity) context).getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE   // 14
                  | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);                                                         // 14   
      } else if (SDK_INT &gt;= SIXTEEN) {
          Log.i("WebViewClient", "hideSystemBar: &gt; 16");
          ((Activity) context).getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE   // 14
                  | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION                                                           // 14
                  | View.SYSTEM_UI_FLAG_FULLSCREEN);                                                              // 16
      } 
  }
  </code></pre>
  
  <p>The problem I'm having is that my webview looses focus when using this. My guess is because of the <code>((Activity) context).getWindow().getDecorView()</code></p>
  
  <p>Is there an alternative way to display the activity on top of the locked screen and hide the system bar without loosing the focus ?</p>
  
  <p>Thank you.</p>