title: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.view.WindowInsets.isConsumed()' on a null object reference
body: <p>I'm working with unity3d by using UnityActivity. I have a MainActivity where starts UnityActivity by</p>
  
  <pre><code>    Intent unity = new Intent(this, UnityActivity.class);
      startActivity(unity);
  </code></pre>
  
  <p>UnityActivity and MainActivity are both</p>
  
  <pre><code>launchMode="singleTask"
  </code></pre>
  
  <p>After working with unity, I call the code below</p>
  
  <pre><code>UnityActivity.this.finish();
  </code></pre>
  
  <p>And I get the error:</p>
  
  <pre><code>    D/MainActivity(25562): onStart
      D/MainActivity(25562): onResume
      D/AndroidRuntime(25562): Shutting down VM
      E/AndroidRuntime(25562): FATAL EXCEPTION: main
      E/AndroidRuntime(25562): Process: ru.mdinc.mdinc, PID: 25562
      E/AndroidRuntime(25562): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.view.WindowInsets.isConsumed()' on a null object reference
      E/AndroidRuntime(25562):    at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7077)
      E/AndroidRuntime(25562):    at android.view.ViewRootImpl.dispatchApplyInsets(ViewRootImpl.java:1670)
      E/AndroidRuntime(25562):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2083)
      E/AndroidRuntime(25562):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1468)
      E/AndroidRuntime(25562):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7208)
      E/AndroidRuntime(25562):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1004)
      E/AndroidRuntime(25562):    at android.view.Choreographer.doCallbacks(Choreographer.java:816)
      E/AndroidRuntime(25562):    at android.view.Choreographer.doFrame(Choreographer.java:751)
      E/AndroidRuntime(25562):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:990)
      E/AndroidRuntime(25562):    at android.os.Handler.handleCallback(Handler.java:873)
      E/AndroidRuntime(25562):    at android.os.Handler.dispatchMessage(Handler.java:99)
      E/AndroidRuntime(25562):    at android.os.Looper.loop(Looper.java:193)
      E/AndroidRuntime(25562):    at android.app.ActivityThread.main(ActivityThread.java:6762)
      E/AndroidRuntime(25562):    at java.lang.reflect.Method.invoke(Native Method)
      E/AndroidRuntime(25562):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
      E/AndroidRuntime(25562):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
  </code></pre>
  
  <p>I did not override any methods of WindowInsets, so don't put links like "you forget initialize variable before using it"</p>
  
  <p>I expect that UnityActivity will be closed and MainActivity restart with previous state.</p>
  
  <p>Before adding functionality with Vuforia that code was working fine.</p>
  
  <p>EDIT: found that error occurs <a href="https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/view/ViewGroup.java#7105" rel="nofollow noreferrer">here</a></p>