title: Is there an API to detect which theme the OS is using - dark or light (or other)?
body: <h2>Background</h2>
  
  <p>On recent Android versions, ever since Android 8.1, the OS got more and more support for themes. More specifically dark theme.</p>
  
  <h2>The problem</h2>
  
  <p>Even though there is a lot of talk about dark mode in the point-of-view for users, there is almost nothing that's written for developers.</p>
  
  <h2>What I've found</h2>
  
  <p>Starting from Android 8.1, Google provided some sort of dark theme . If the user chooses to have a dark wallpaper, some UI components of the OS would turn black (article <a href="https://www.theandroidsoul.com/dark-theme-android-8-1-oreo/" rel="noreferrer"><strong>here</strong></a>). </p>
  
  <p>In addition, if you developed a live wallpaper app, you could tell the OS which colors it has (3 types of colors), which affected the OS colors too (at least on Vanilla based ROMs and on Google devices). That's why I even made an app that lets you have any wallpaper while still be able to choose the colors (<a href="https://play.google.com/store/apps/details?id=com.lb.lwp_plus" rel="noreferrer"><strong>here</strong></a>). This is done by calling <a href="https://developer.android.com/reference/android/service/wallpaper/WallpaperService.Engine.html#notifyColorsChanged()" rel="noreferrer"><strong>notifyColorsChanged</strong></a> and then provide them using <a href="https://developer.android.com/reference/android/service/wallpaper/WallpaperService.Engine.html#onComputeColors()" rel="noreferrer"><strong>onComputeColors</strong></a></p>
  
  <p>Starting from Android 9.0, it is now possible to choose which theme to have: light, dark or automatic (based on wallpaper) :</p>
  
  <p><a href="https://i.stack.imgur.com/CKZdV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CKZdV.png" alt="enter image description here"></a></p>
  
  <p>And now on the near Android Q , it seems it went further, yet it's still unclear to what extent. Somehow a launcher called "Smart Launcher" has ridden on it, offering to use the theme right on itself (article <a href="https://www.androidcentral.com/smart-launcher-5-adds-android-q-dark-theme-support" rel="noreferrer"><strong>here</strong></a>). So, if you enable dark mode (manually, as written <a href="https://www.xda-developers.com/android-q-toggle-dark-theme/" rel="noreferrer"><strong>here</strong></a>) , you get the app's settings screen as such:</p>
  
  <p><a href="https://i.stack.imgur.com/W43vo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/W43vo.png" alt="enter image description here"></a></p>
  
  <p>The only thing I've found so far is the above articles, and that I'm following this kind of topic.</p>
  
  <p>I also know how to request the OS to change color using the live wallpaper, but this seems to be changing on Android Q, at least according to what I've seen when trying it (I think it's more based on time-of-day, but not sure).</p>
  
  <h2>The questions</h2>
  
  <ol>
  <li><p>Is there an API to get which colors the OS is set to use ? </p></li>
  <li><p>Is there any kind of API to get the theme of the OS ? From which version?</p></li>
  <li><p>Is the new API somehow related to night mode too? How do those work together?</p></li>
  <li><p>Is there a nice API for apps to handle the chosen theme? Meaning that if the OS is in certain theme, so will the current app?</p></li>
  </ol>