title: Android Can we hide status bar when onAttachedToWindow() is called?
body: <p>There is a way to hide the status bar or disable it when the onAttachedToWindow is called and window type is keyguard ??
  I have tried this on my activity class:</p>
  
  <p>and this is onCreate</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setWindowAnimations(0);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setContentView(R.layout.activity_lock); 
  }
  
  public void onAttachedToWindow() {
      super.onAttachedToWindow();
      getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  }
  </code></pre>
  
  <p>and this in my manifest</p>
  
  <pre><code>android:theme="@android:style/Theme.NoTitleBar.Fullscreen";
  </code></pre>
  
  <p><em><strong>but sometimes the status bar disappears, and other times it appears.</em></strong></p>
  
  <p>If i try this:</p>
  
  <pre><code>public void onAttachedToWindow() {
      super.onAttachedToWindow();
      getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  }
  </code></pre>
  
  <p>it gives me the error:</p>
  
  <pre><code>12-22 11:03:51.209: E/AndroidRuntime(9088): android.util.AndroidRuntimeException: requestFeature() must be called before adding content
  </code></pre>