diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java index 26bfbf7e46..ff5b7081cf 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java @@ -209,6 +209,14 @@ public class FlutterActivity extends Activity implements FlutterActivityAndFragmentDelegate.Host, LifecycleOwner { private static final String TAG = "FlutterActivity"; + /** + * The ID of the {@code FlutterView} created by this activity. + * + *

This ID can be used to lookup {@code FlutterView} in the Android view hierarchy. For more, + * see {@link android.view.View#findViewById}. + */ + public static final int FLUTTER_VIEW_ID = 0xF1F2; + /** * Creates an {@link Intent} that launches a {@code FlutterActivity}, which creates a {@link * FlutterEngine} that executes a {@code main()} Dart entrypoint, and displays the "/" route as @@ -424,7 +432,11 @@ public class FlutterActivity extends Activity lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_CREATE); configureWindowForTransparency(); - setContentView(createFlutterView()); + + View flutterView = createFlutterView(); + flutterView.setId(FLUTTER_VIEW_ID); + setContentView(flutterView); + configureStatusBarForFullscreenFlutterExperience(); } diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityTest.java index 303800decc..9626836772 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityTest.java @@ -68,6 +68,17 @@ public class FlutterActivityTest { FlutterInjector.reset(); } + @Test + public void flutterViewHasId() { + Intent intent = FlutterActivity.createDefaultIntent(RuntimeEnvironment.application); + ActivityController activityController = + Robolectric.buildActivity(FlutterActivity.class, intent); + FlutterActivity activity = activityController.get(); + + activity.onCreate(null); + assertNotNull(activity.findViewById(FlutterActivity.FLUTTER_VIEW_ID)); + } + @Test public void itCreatesDefaultIntentWithExpectedDefaults() { Intent intent = FlutterActivity.createDefaultIntent(RuntimeEnvironment.application);