@@ -581,7 +581,7 @@ public boolean onPreDraw() {
581581 void onResume () {
582582 Log .v (TAG , "onResume()" );
583583 ensureAlive ();
584- if (host .shouldDispatchAppLifecycleState ()) {
584+ if (host .shouldDispatchAppLifecycleState () && flutterEngine != null ) {
585585 // This may notify in a redundant fashion with onWindowFocusChanged. The
586586 // lifecycle channel will deduplicate, but since the Android documentation
587587 // says that we shouldn't rely on any particular order between lifecycle
@@ -633,7 +633,7 @@ void updateSystemUiOverlays() {
633633 void onPause () {
634634 Log .v (TAG , "onPause()" );
635635 ensureAlive ();
636- if (host .shouldDispatchAppLifecycleState ()) {
636+ if (host .shouldDispatchAppLifecycleState () && flutterEngine != null ) {
637637 // This may notify in a redundant fashion with onWindowFocusChanged. The
638638 // lifecycle channel will deduplicate, but since the Android documentation
639639 // says that we shouldn't rely on any particular order between lifecycle
@@ -660,7 +660,7 @@ void onStop() {
660660 Log .v (TAG , "onStop()" );
661661 ensureAlive ();
662662
663- if (host .shouldDispatchAppLifecycleState ()) {
663+ if (host .shouldDispatchAppLifecycleState () && flutterEngine != null ) {
664664 flutterEngine .getLifecycleChannel ().appIsPaused ();
665665 }
666666
@@ -766,7 +766,7 @@ void onDetach() {
766766 platformPlugin = null ;
767767 }
768768
769- if (host .shouldDispatchAppLifecycleState ()) {
769+ if (host .shouldDispatchAppLifecycleState () && flutterEngine != null ) {
770770 flutterEngine .getLifecycleChannel ().appIsDetached ();
771771 }
772772
@@ -909,8 +909,8 @@ void onUserLeaveHint() {
909909 */
910910 void onWindowFocusChanged (boolean hasFocus ) {
911911 ensureAlive ();
912- Log .w (TAG , "Received onWindowFocusChanged: " + (hasFocus ? "true" : "false" ));
913- if (host .shouldDispatchAppLifecycleState ()) {
912+ Log .v (TAG , "Received onWindowFocusChanged: " + (hasFocus ? "true" : "false" ));
913+ if (host .shouldDispatchAppLifecycleState () && flutterEngine != null ) {
914914 // This may notify in a redundant fashion with onResume and onPause. The
915915 // lifecycle channel will deduplicate, but since the Android documentation
916916 // says that we shouldn't rely on any particular order between lifecycle
0 commit comments