File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
io/flutter/embedding/android
test/io/flutter/embedding/android Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,14 @@ public class FlutterActivity extends Activity
209209 implements FlutterActivityAndFragmentDelegate .Host , LifecycleOwner {
210210 private static final String TAG = "FlutterActivity" ;
211211
212+ /**
213+ * The ID of the {@code FlutterView} created by this activity.
214+ *
215+ * <p>This ID can be used to lookup {@code FlutterView} in the Android view hierarchy. For more,
216+ * see {@link android.view.View#findViewById}.
217+ */
218+ public static final int FLUTTER_VIEW_ID = 0xF1F2 ;
219+
212220 /**
213221 * Creates an {@link Intent} that launches a {@code FlutterActivity}, which creates a {@link
214222 * FlutterEngine} that executes a {@code main()} Dart entrypoint, and displays the "/" route as
@@ -424,7 +432,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
424432 lifecycle .handleLifecycleEvent (Lifecycle .Event .ON_CREATE );
425433
426434 configureWindowForTransparency ();
427- setContentView (createFlutterView ());
435+
436+ View flutterView = createFlutterView ();
437+ flutterView .setId (FLUTTER_VIEW_ID );
438+ setContentView (flutterView );
439+
428440 configureStatusBarForFullscreenFlutterExperience ();
429441 }
430442
Original file line number Diff line number Diff line change @@ -68,6 +68,17 @@ public void tearDown() {
6868 FlutterInjector .reset ();
6969 }
7070
71+ @ Test
72+ public void flutterViewHasId () {
73+ Intent intent = FlutterActivity .createDefaultIntent (RuntimeEnvironment .application );
74+ ActivityController <FlutterActivity > activityController =
75+ Robolectric .buildActivity (FlutterActivity .class , intent );
76+ FlutterActivity activity = activityController .get ();
77+
78+ activity .onCreate (null );
79+ assertNotNull (activity .findViewById (FlutterActivity .FLUTTER_VIEW_ID ));
80+ }
81+
7182 @ Test
7283 public void itCreatesDefaultIntentWithExpectedDefaults () {
7384 Intent intent = FlutterActivity .createDefaultIntent (RuntimeEnvironment .application );
You can’t perform that action at this time.
0 commit comments