Reland "Exit on deprecated v1 embedding when trying to run or build" (#92901) (#93566)

This commit is contained in:
Gary Qian
2021-11-12 15:52:32 -08:00
committed by GitHub
parent ee49e8df3f
commit 02b1146cff
33 changed files with 348 additions and 107 deletions

View File

@@ -11,14 +11,15 @@ found in the LICENSE file. -->
-->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
<!-- ${applicationName} is used by the Flutter tool to select the Application
class to use. For most apps, this is the default Android application.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application android:name="io.flutter.app.FlutterApplication" android:label="Platform Interaction" android:icon="@mipmap/ic_launcher">
Application and put your custom class here. -->
<application android:name="${applicationName}" android:label="Platform Interaction" android:icon="@mipmap/ic_launcher">
<activity android:name="com.yourcompany.platforminteraction.MainActivity"
android:launchMode="singleTop"
android:exported="true"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
@@ -28,5 +29,10 @@ found in the LICENSE file. -->
<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>

View File

@@ -6,19 +6,22 @@ package com.yourcompany.platforminteraction;
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugin.common.*;
import io.flutter.plugins.GeneratedPluginRegistrant;
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.StringCodec;
public class MainActivity extends FlutterActivity {
BasicMessageChannel channel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
channel =
new BasicMessageChannel<>(flutterEngine.getDartExecutor().getBinaryMessenger(), "navigation-test", StringCodec.INSTANCE);
}
public void finish() {
BasicMessageChannel channel =
new BasicMessageChannel<>(getFlutterView(), "navigation-test", StringCodec.INSTANCE);
channel.send("ping");
}
}