Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e29c0ce

Browse files
committed
Add some null checks
1 parent 57268ba commit e29c0ce

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

shell/platform/android/io/flutter/embedding/engine/systemchannels/LifecycleChannel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ private void sendState(String state) {
3838
if (lastState == state) {
3939
return;
4040
}
41-
Log.e(TAG, "Sending " + state + " message.");
4241
lastState = state;
4342
channel.send(state);
4443
}

0 commit comments

Comments
 (0)