How do you change the nav-bar background (not just color), even when not in foreground?
<h2>Background</h2>

<p>Somehow the app "<a href="https://play.google.com/store/apps/details?id=pl.damianpiwowarski.navbarapps" rel="noreferrer"><strong>Navbar Apps</strong></a>" allows to customize the background of the nav bar, even if it's not in the foreground, and even not just a simple color.</p>

<p><a href="https://i.stack.imgur.com/7Yeae.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7Yeae.png" alt="enter image description here"></a></p>

<h2>The problem</h2>

<p>I thought it's only possible to change the color of it, and only when the app is in the foreground...</p>

<p>I've seen it on some custom roms, even having special effects when music plays, but I didn't know it's possible to customize it even without a custom rom (or root).</p>

<h2>The questions</h2>

<ol>
<li><p>Is it a hack? How do they change, not just the color of the navigation bar, but even set a background image for it (including dynamic one, for battery status) ?</p></li>
<li><p>Is it also possible to change other system bars, like the notification bar? </p></li>
<li><p>How does it check which app is in the foreground (needed for deciding when to change the color, based on current app, probably)? Is it a new API ? I thought that the API for getting the foreground activity got deprecated and now doesn't help in any way...</p></li>
</ol>