diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
index 4ca426491afa1..24689fc40ace1 100644
--- a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
+++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
@@ -12,7 +12,6 @@
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
-import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
@@ -238,8 +237,14 @@ void onAttach(@NonNull Context context) {
*
*
{@code inflater} and {@code container} may be null when invoked from an {@code Activity}.
*
- *
This method creates a new {@link FlutterView}, adds a {@link FlutterUiDisplayListener} to
- * it, and then returns it.
+ *
This method:
+ *
+ *
+ * - creates a new {@link FlutterView} in a {@code View} hierarchy
+ *
- adds a {@link FlutterUiDisplayListener} to it
+ *
- attaches a {@link FlutterEngine} to the new {@link FlutterView}
+ *
- returns the new {@code View} hierarchy
+ *
*/
@NonNull
View onCreateView(
@@ -261,6 +266,9 @@ View onCreateView(
}
flutterSplashView.displayFlutterViewWithSplash(flutterView, host.provideSplashScreen());
+ Log.v(TAG, "Attaching FlutterEngine to FlutterView.");
+ flutterView.attachToFlutterEngine(flutterEngine);
+
return flutterSplashView;
}
@@ -281,31 +289,13 @@ void onActivityCreated(@Nullable Bundle bundle) {
*
*
*
- * - Attaches the {@link FlutterEngine} owned by this delegate to the {@link FlutterView}
- * owned by this delegate.
*
- Begins executing Dart code, if it is not already executing.
*
*/
void onStart() {
Log.v(TAG, "onStart()");
ensureAlive();
-
- // We post() the code that attaches the FlutterEngine to our FlutterView because there is
- // some kind of blocking logic on the native side when the surface is connected. That lag
- // causes launching Activitys to wait a second or two before launching. By post()'ing this
- // behavior we are able to move this blocking logic to after the Activity's launch.
- // TODO(mattcarroll): figure out how to avoid blocking the MAIN thread when connecting a surface
- new Handler()
- .post(
- new Runnable() {
- @Override
- public void run() {
- Log.v(TAG, "Attaching FlutterEngine to FlutterView.");
- flutterView.attachToFlutterEngine(flutterEngine);
-
- doInitialFlutterViewRun();
- }
- });
+ doInitialFlutterViewRun();
}
/**
@@ -418,7 +408,6 @@ void onStop() {
Log.v(TAG, "onStop()");
ensureAlive();
flutterEngine.getLifecycleChannel().appIsPaused();
- flutterView.detachFromFlutterEngine();
}
/**
@@ -429,6 +418,8 @@ void onStop() {
void onDestroyView() {
Log.v(TAG, "onDestroyView()");
ensureAlive();
+
+ flutterView.detachFromFlutterEngine();
flutterView.removeOnFirstFrameRenderedListener(flutterUiDisplayListener);
}