Android M Light and Dark status bar programmatically - how to make it dark again?
<p>In the Android M we have ability to make status bar icons dark. To do that we can specify attribute in the theme's xml:</p>

<pre><code>&lt;item name="android:windowLightStatusBar"&gt;true&lt;/item&gt;
</code></pre>

<p>OR we cat set it at runtime with this code:</p>

<pre><code>View someView = findViewById(R.id.some_view);
if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
    someView.setSystemUiVisibility(someView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
</code></pre>

<p>And it actually works fine. But question is how to properly set a status bar mode to dark at runtime?</p>

<p>I already tried these variants:</p>

<pre><code>// Makes status bar mode dark, but also hides it along with all navigation views. 
someView.setSystemUiVisibility(someView.getSystemUiVisibility() | ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

// Does nothing 
someView.setSystemUiVisibility(someView.getSystemUiVisibility() &amp; ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

// Also does nothing 
someView.setSystemUiVisibility(someView.getSystemUiVisibility() ^ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
</code></pre>

<p>So how it can be done the right way?</p>