Reland: Migrate examples to Android embedding v2 (#44139)
This commit is contained in:
@@ -17,17 +17,15 @@
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="stateVisible|adjustResize">
|
||||
<!-- This keeps the window background of the activity showing
|
||||
until Flutter renders its first frame. It can be removed if
|
||||
there is no splash screen (such as the default splash screen
|
||||
defined in @style/LaunchTheme). -->
|
||||
<meta-data
|
||||
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
|
||||
android:value="true" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -5,7 +5,10 @@ import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import io.flutter.app.FlutterActivity
|
||||
import androidx.annotation.NonNull
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.StandardMessageCodec
|
||||
import io.flutter.plugin.platform.PlatformView
|
||||
@@ -27,11 +30,11 @@ class MainActivity : FlutterActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
GeneratedPluginRegistrant.registerWith(this)
|
||||
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
|
||||
GeneratedPluginRegistrant.registerWith(flutterEngine);
|
||||
|
||||
registrarFor("com.example.abstract_method_smoke_test")
|
||||
val shimPluginRegistry = ShimPluginRegistry(flutterEngine);
|
||||
shimPluginRegistry.registrarFor("com.example.abstract_method_smoke_test")
|
||||
.platformViewRegistry()
|
||||
.registerViewFactory("simple", object : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
|
||||
override fun create(context: Context?, viewId: Int, args: Any?): PlatformView {
|
||||
@@ -41,7 +44,7 @@ class MainActivity : FlutterActivity() {
|
||||
|
||||
// Triggers the Android keyboard, which causes the resize of the Flutter view.
|
||||
// We need to wait for the app to complete.
|
||||
MethodChannel(flutterView, "com.example.abstract_method_smoke_test")
|
||||
MethodChannel(flutterEngine.getDartExecutor(), "com.example.abstract_method_smoke_test")
|
||||
.setMethodCallHandler { _, result ->
|
||||
toggleInput()
|
||||
result.success(null)
|
||||
|
||||
Reference in New Issue
Block a user