title: To implement Android night mode, using UiModeManager and enable car mode, but show a notification, it may not the good way
body: <p>I want to implement night mode in my APP (manually switch day and night mode), and I learned that I can use <code>UiModeManager.setNightMode()</code> and add some resources like <code>values-night</code> and <code>drawable-night</code> to archive it.</p>
  <p>In document, before <code>setNightMode()</code>, we need to <code>enableCarMode()</code>.</p>
  <p>Using code like below can work, but problem appeared.</p>
  <pre><code>UiModeManager uiManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE);
  if (isNightMode) {
      uiManager.enableCarMode(0);
      uiManager.setNightMode(UiModeManager.MODE_NIGHT_YES);
  } else {
      uiManager.disableCarMode(0);
      uiManager.setNightMode(UiModeManager.MODE_NIGHT_NO);
  }
  </code></pre>
  <p>It shows a notification to allow user to exit car mode.</p>
  <p><a href="https://i.stack.imgur.com/1noBv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1noBv.png" alt="enter image description here" /></a></p>
  <p>Do you have any idea to disable this notification?</p>
  <p>Or these just means it is not the best way to implement android night mode. And enabling car mode would make any strange difference to my APP or my phone?</p>
  <p>PS: I wonder that why we need to enable car mode before setting night mode. Is there some deep consideration in this?</p>
  <p>PPS: I already know that I can change theme to switch day and night mode. It needs to call <code>this.recreate()</code> and causes screen to flicker for a second.</p>
  <p>PPPS: If <code>UiModeManager.setNightMode</code> and <code>change theme</code> are neither best way to implement night mode, what else choice do I have?</p>
  <p><strong>Edit:</strong></p>
  <p>Method 1: <code>UiModeManager.setNightMode</code></p>
  <p><a href="https://i.stack.imgur.com/9fyuY.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/9fyuY.gif" alt="enter image description here" /></a></p>
  <p>Method 2: <code>change theme</code></p>
  <p><a href="https://i.stack.imgur.com/IMbqs.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/IMbqs.gif" alt="enter image description here" /></a></p>
  <p><strong>Edit again:</strong></p>
  <p>I think my idea was wrong. It is meaningless to disable the notification, but allow the car mode.</p>
  <p>All I want is to implement night mode like Method 1, without setting something like desk or car mode, without showing flicker.</p>
  <p><strong>Finally</strong></p>
  <p>Using <code>UiModeManager.setNightMode</code> and enabling car mode are not the good way to implement night mode. Because it makes some effect in Android 5.0 and above.</p>
  <p>When car mode is enabled and APP is running, I pressed home button, something strange happened (Test in nexus 7 Android 5.1.1). As the picture showed below:</p>
  <blockquote>
  <p>Launch Android Auto</p>
  <p>Look for the Android Auto button on your car's display to start</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/8Z7BL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8Z7BL.png" alt="enter image description here" /></a></p>
  <p>Unfortunately, <code>UiModeManager.setNightMode</code> can't be used unless car mode is needed.</p>
  <p>Except car mode is enabled, the result is perfect and for developers it can just make some folders like <code>drawable-night</code> and <code>values-night</code> without change too much code. While mode is changed, it sends broadcast and switches the system configuration to the appropriate UI mode.</p>
  <p><strong>Although there are so many benefits, it is the wrong way to night mode.</strong></p>
  <p>I still wonder why car mode and night mode is combined so closely.</p>