title: Battery saver (and Night mode) on Android 9 Pie relaunches whole activity, how to prevent this?
body: <p>When I run my app on device (Google Pixel 2) with Android 9 Pie and switch on (or switch off) battery saver, whole activity immediately relaunches.
  When I switch on battery saver on lower versions of Android like 6, 7 and 8, app continues normally without relaunching. Is it possible to prevent these relaunches on Android 9 too?</p>
  
  <p>I investigated it and found, that when you switch on Battery saver, even new native Night mode is switched on automatically. So I tried to switch on only Night Mode via "Settings - Developer Options" and it relaunched activity in the same way as switching on Battery Saver. So this relaunching can be caused by Night mode.</p>
  
  <p><em>Note: don't confuse "Night light", "Dark theme" and "Night Mode", these are different things and problem is only with "Night mode".</em></p>
  
  <p>This is stacktrace from debugger, where can be seen, that OS tries to relaunch activity by stopping it (and then it creates it again).</p>
  
  <pre><code>onStop:579, MyActivity (com.mypackage)
  callActivityOnStop:1432, Instrumentation (android.app)
  performStop:7375, Activity (android.app)
  callActivityOnStop:4181, ActivityThread (android.app)
  handleRelaunchActivityInner:4796, ActivityThread (android.app)
  handleRelaunchActivity:4732, ActivityThread (android.app)
  execute:69, ActivityRelaunchItem (android.app.servertransaction)
  executeCallbacks:108, TransactionExecutor (android.app.servertransaction)
  execute:68, TransactionExecutor (android.app.servertransaction)
  handleMessage:1816, ActivityThread$H (android.app)
  dispatchMessage:106, Handler (android.os)
  loop:193, Looper (android.os)
  main:6718, ActivityThread (android.app)
  invoke:-1, Method (java.lang.reflect)
  run:493, RuntimeInit$MethodAndArgsCaller (com.android.internal.os)
  main:858, ZygoteInit (com.android.internal.os)
  </code></pre>
  
  <p>I read here <a href="https://developer.android.com/about/versions/pie/power" rel="nofollow noreferrer">https://developer.android.com/about/versions/pie/power</a>, that on new Android there are some changes in Battery Saver, but I didn't find any details and any advices for fixing possible problems.
  Can you please help me?</p>
  
  <p><strong>Actual result</strong>: I run my app and switch on/off battery saver -> whole main activity relaunches, so it is stopped and then it tries to run as newly created.</p>
  
  <p><strong>Expected result</strong>: I run my app and switch on/off battery saver -> nothing happens with my app, it continues with it's main activity as nothing happened.</p>
  
  <p>Thank you in advance.</p>