Unverified Commit ea4da39f authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Revert: Migrate examples to the new embedding (#43689)

parent f41becf5
...@@ -23,15 +23,17 @@ ...@@ -23,15 +23,17 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"> android:windowSoftInputMode="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> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
package com.example.macrobenchmarks; package com.example.macrobenchmarks;
import androidx.annotation.NonNull; import android.os.Bundle;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
} }
} }
...@@ -17,15 +17,17 @@ ...@@ -17,15 +17,17 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:windowSoftInputMode="stateVisible|adjustResize"> 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> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
...@@ -5,15 +5,12 @@ import android.graphics.Color ...@@ -5,15 +5,12 @@ import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import androidx.annotation.NonNull import io.flutter.app.FlutterActivity
import dev.flutter.plugins.GeneratedPluginRegistrant
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.MethodChannel
import io.flutter.plugin.common.StandardMessageCodec import io.flutter.plugin.common.StandardMessageCodec
import io.flutter.plugin.platform.PlatformView import io.flutter.plugin.platform.PlatformView
import io.flutter.plugin.platform.PlatformViewFactory import io.flutter.plugin.platform.PlatformViewFactory
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity : FlutterActivity() { class MainActivity : FlutterActivity() {
class SimplePlatformView(context: Context) : PlatformView { class SimplePlatformView(context: Context) : PlatformView {
...@@ -30,11 +27,11 @@ class MainActivity : FlutterActivity() { ...@@ -30,11 +27,11 @@ class MainActivity : FlutterActivity() {
} }
} }
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { override fun onCreate(savedInstanceState: Bundle?) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this)
val shimPluginRegistry = ShimPluginRegistry(flutterEngine); registrarFor("com.example.abstract_method_smoke_test")
shimPluginRegistry.registrarFor("com.example.abstract_method_smoke_test")
.platformViewRegistry() .platformViewRegistry()
.registerViewFactory("simple", object : PlatformViewFactory(StandardMessageCodec.INSTANCE) { .registerViewFactory("simple", object : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
override fun create(context: Context?, viewId: Int, args: Any?): PlatformView { override fun create(context: Context?, viewId: Int, args: Any?): PlatformView {
...@@ -44,7 +41,7 @@ class MainActivity : FlutterActivity() { ...@@ -44,7 +41,7 @@ class MainActivity : FlutterActivity() {
// Triggers the Android keyboard, which causes the resize of the Flutter view. // Triggers the Android keyboard, which causes the resize of the Flutter view.
// We need to wait for the app to complete. // We need to wait for the app to complete.
MethodChannel(flutterEngine.getDartExecutor(), "com.example.abstract_method_smoke_test") MethodChannel(flutterView, "com.example.abstract_method_smoke_test")
.setMethodCallHandler { _, result -> .setMethodCallHandler { _, result ->
toggleInput() toggleInput()
result.success(null) result.success(null)
......
...@@ -5,9 +5,12 @@ import android.util.Log; ...@@ -5,9 +5,12 @@ import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.flutter.embedding.android.FlutterActivity; import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.android.FlutterView; import io.flutter.embedding.android.FlutterView;
import io.flutter.embedding.android.SplashScreen; import io.flutter.embedding.android.SplashScreen;
......
...@@ -24,10 +24,5 @@ ...@@ -24,10 +24,5 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
...@@ -9,26 +9,22 @@ import java.nio.ByteBuffer; ...@@ -9,26 +9,22 @@ import java.nio.ByteBuffer;
import java.util.Date; import java.util.Date;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.dart.DartExecutor;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.*; import io.flutter.plugin.common.*;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
DartExecutor dartExecutor = flutterEngine.getDartExecutor(); setupMessageHandshake(new BasicMessageChannel<>(getFlutterView(), "binary-msg", BinaryCodec.INSTANCE));
setupMessageHandshake(new BasicMessageChannel<>(dartExecutor, "binary-msg", BinaryCodec.INSTANCE)); setupMessageHandshake(new BasicMessageChannel<>(getFlutterView(), "string-msg", StringCodec.INSTANCE));
setupMessageHandshake(new BasicMessageChannel<>(dartExecutor, "string-msg", StringCodec.INSTANCE)); setupMessageHandshake(new BasicMessageChannel<>(getFlutterView(), "json-msg", JSONMessageCodec.INSTANCE));
setupMessageHandshake(new BasicMessageChannel<>(dartExecutor, "json-msg", JSONMessageCodec.INSTANCE)); setupMessageHandshake(new BasicMessageChannel<>(getFlutterView(), "std-msg", ExtendedStandardMessageCodec.INSTANCE));
setupMessageHandshake(new BasicMessageChannel<>(dartExecutor, "std-msg", ExtendedStandardMessageCodec.INSTANCE)); setupMethodHandshake(new MethodChannel(getFlutterView(), "json-method", JSONMethodCodec.INSTANCE));
setupMethodHandshake(new MethodChannel(dartExecutor, "json-method", JSONMethodCodec.INSTANCE)); setupMethodHandshake(new MethodChannel(getFlutterView(), "std-method", new StandardMethodCodec(ExtendedStandardMessageCodec.INSTANCE)));
setupMethodHandshake(new MethodChannel(dartExecutor, "std-method", new StandardMethodCodec(ExtendedStandardMessageCodec.INSTANCE)));
} }
private <T> void setupMessageHandshake(final BasicMessageChannel<T> channel) { private <T> void setupMessageHandshake(final BasicMessageChannel<T> channel) {
......
...@@ -24,10 +24,5 @@ ...@@ -24,10 +24,5 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
package com.yourcompany.platforminteraction; package com.yourcompany.platforminteraction;
import androidx.annotation.NonNull; import android.os.Bundle;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
} }
} }
...@@ -24,10 +24,5 @@ ...@@ -24,10 +24,5 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
package com.yourcompany.animated_list; package com.yourcompany.animated_list;
import androidx.annotation.NonNull; import android.os.Bundle;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
} }
} }
...@@ -29,10 +29,5 @@ ...@@ -29,10 +29,5 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
...@@ -5,26 +5,25 @@ ...@@ -5,26 +5,25 @@
package io.flutter.demo.gallery; package io.flutter.demo.gallery;
import android.os.ConditionVariable; import android.os.ConditionVariable;
import androidx.annotation.NonNull;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.view.FlutterView;
/** Instrumentation for testing using Android Espresso framework. */ /** Instrumentation for testing using Android Espresso framework. */
public class FlutterGalleryInstrumentation implements MethodCallHandler { public class FlutterGalleryInstrumentation implements MethodCallHandler {
private final ConditionVariable testFinished = new ConditionVariable(); private final ConditionVariable testFinished = new ConditionVariable();
private volatile boolean testSuccessful; private volatile boolean testSuccessful;
FlutterGalleryInstrumentation(@NonNull BinaryMessenger messenger) { FlutterGalleryInstrumentation(FlutterView view) {
new MethodChannel(messenger, "io.flutter.demo.gallery/TestLifecycleListener") new MethodChannel(view, "io.flutter.demo.gallery/TestLifecycleListener")
.setMethodCallHandler(this); .setMethodCallHandler(this);
} }
@Override @Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { public void onMethodCall(MethodCall call, Result result) {
testSuccessful = call.method.equals("success"); testSuccessful = call.method.equals("success");
testFinished.open(); testFinished.open();
result.success(null); result.success(null);
......
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
package io.flutter.demo.gallery; package io.flutter.demo.gallery;
import androidx.annotation.NonNull; import android.os.Build;
import dev.flutter.plugins.GeneratedPluginRegistrant; import android.os.Bundle;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine; import io.flutter.app.FlutterActivity;
import io.flutter.view.FlutterView;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
private FlutterGalleryInstrumentation instrumentation; private FlutterGalleryInstrumentation instrumentation;
/** Instrumentation for testing. */ /** Instrumentation for testing. */
...@@ -18,8 +21,19 @@ public class MainActivity extends FlutterActivity { ...@@ -18,8 +21,19 @@ public class MainActivity extends FlutterActivity {
} }
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
instrumentation = new FlutterGalleryInstrumentation(flutterEngine.getDartExecutor()); GeneratedPluginRegistrant.registerWith(this);
instrumentation = new FlutterGalleryInstrumentation(this.getFlutterView());
getFlutterView().addFirstFrameListener(new FlutterView.FirstFrameListener() {
@Override
public void onFirstFrame() {
// Report fully drawn time for Play Store Console.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
MainActivity.this.reportFullyDrawn();
}
MainActivity.this.getFlutterView().removeFirstFrameListener(this);
}
});
} }
} }
...@@ -29,10 +29,5 @@ ...@@ -29,10 +29,5 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
package io.flutter.examples.hello_world; package io.flutter.examples.hello_world;
import androidx.annotation.NonNull; import android.os.Bundle;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
} }
} }
...@@ -18,15 +18,17 @@ ...@@ -18,15 +18,17 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"> android:windowSoftInputMode="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> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
package com.example.image_list; package com.example.image_list;
import androidx.annotation.NonNull; import android.os.Bundle;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
} }
} }
...@@ -24,10 +24,5 @@ ...@@ -24,10 +24,5 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
...@@ -4,14 +4,15 @@ ...@@ -4,14 +4,15 @@
package io.flutter.examples.Layers; package io.flutter.examples.Layers;
import androidx.annotation.NonNull; import android.os.Bundle;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
} }
} }
...@@ -21,10 +21,5 @@ ...@@ -21,10 +21,5 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
...@@ -13,10 +13,8 @@ import android.os.BatteryManager; ...@@ -13,10 +13,8 @@ import android.os.BatteryManager;
import android.os.Build.VERSION; import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES; import android.os.Build.VERSION_CODES;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.EventChannel; import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.EventChannel.EventSink; import io.flutter.plugin.common.EventChannel.EventSink;
import io.flutter.plugin.common.EventChannel.StreamHandler; import io.flutter.plugin.common.EventChannel.StreamHandler;
...@@ -24,16 +22,17 @@ import io.flutter.plugin.common.MethodChannel; ...@@ -24,16 +22,17 @@ import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
private static final String BATTERY_CHANNEL = "samples.flutter.io/battery"; private static final String BATTERY_CHANNEL = "samples.flutter.io/battery";
private static final String CHARGING_CHANNEL = "samples.flutter.io/charging"; private static final String CHARGING_CHANNEL = "samples.flutter.io/charging";
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { public void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
new EventChannel(flutterEngine.getDartExecutor(), CHARGING_CHANNEL).setStreamHandler( new EventChannel(getFlutterView(), CHARGING_CHANNEL).setStreamHandler(
new StreamHandler() { new StreamHandler() {
private BroadcastReceiver chargingStateChangeReceiver; private BroadcastReceiver chargingStateChangeReceiver;
@Override @Override
...@@ -51,7 +50,7 @@ public class MainActivity extends FlutterActivity { ...@@ -51,7 +50,7 @@ public class MainActivity extends FlutterActivity {
} }
); );
new MethodChannel(flutterEngine.getDartExecutor(), BATTERY_CHANNEL).setMethodCallHandler( new MethodChannel(getFlutterView(), BATTERY_CHANNEL).setMethodCallHandler(
new MethodCallHandler() { new MethodCallHandler() {
@Override @Override
public void onMethodCall(MethodCall call, Result result) { public void onMethodCall(MethodCall call, Result result) {
......
package com.example.platformchannel; package com.example.platformchannel;
import static org.junit.Assert.*;
import android.app.Instrumentation;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule; import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4; import android.support.test.runner.AndroidJUnit4;
import io.flutter.view.FlutterView; import io.flutter.view.FlutterView;
import android.app.Instrumentation;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static org.junit.Assert.*;
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest { public class ExampleInstrumentedTest {
@Rule @Rule
......
...@@ -21,10 +21,5 @@ ...@@ -21,10 +21,5 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
...@@ -13,10 +13,8 @@ import android.os.BatteryManager; ...@@ -13,10 +13,8 @@ import android.os.BatteryManager;
import android.os.Build.VERSION; import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES; import android.os.Build.VERSION_CODES;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.EventChannel; import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.EventChannel.EventSink; import io.flutter.plugin.common.EventChannel.EventSink;
import io.flutter.plugin.common.EventChannel.StreamHandler; import io.flutter.plugin.common.EventChannel.StreamHandler;
...@@ -24,16 +22,17 @@ import io.flutter.plugin.common.MethodChannel; ...@@ -24,16 +22,17 @@ import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
private static final String BATTERY_CHANNEL = "samples.flutter.io/battery"; private static final String BATTERY_CHANNEL = "samples.flutter.io/battery";
private static final String CHARGING_CHANNEL = "samples.flutter.io/charging"; private static final String CHARGING_CHANNEL = "samples.flutter.io/charging";
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { public void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
new EventChannel(flutterEngine.getDartExecutor(), CHARGING_CHANNEL).setStreamHandler( new EventChannel(getFlutterView(), CHARGING_CHANNEL).setStreamHandler(
new StreamHandler() { new StreamHandler() {
private BroadcastReceiver chargingStateChangeReceiver; private BroadcastReceiver chargingStateChangeReceiver;
@Override @Override
...@@ -51,7 +50,7 @@ public class MainActivity extends FlutterActivity { ...@@ -51,7 +50,7 @@ public class MainActivity extends FlutterActivity {
} }
); );
new MethodChannel(flutterEngine.getDartExecutor(), BATTERY_CHANNEL).setMethodCallHandler( new MethodChannel(getFlutterView(), BATTERY_CHANNEL).setMethodCallHandler(
new MethodCallHandler() { new MethodCallHandler() {
@Override @Override
public void onMethodCall(MethodCall call, Result result) { public void onMethodCall(MethodCall call, Result result) {
......
...@@ -33,10 +33,5 @@ ...@@ -33,10 +33,5 @@
android:parentActivityName="io.flutter.examples.platform_view.MainActivity" android:parentActivityName="io.flutter.examples.platform_view.MainActivity"
android:theme="@style/Theme.AppCompat.NoActionBar" android:theme="@style/Theme.AppCompat.NoActionBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"></activity> android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"></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> </application>
</manifest> </manifest>
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
package io.flutter.examples.platform_view; package io.flutter.examples.platform_view;
import android.content.Intent; import android.content.Intent;
import androidx.annotation.NonNull; import android.os.Bundle;
import dev.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.app.FlutterActivity;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
private static final String CHANNEL = "samples.flutter.io/platform_view"; private static final String CHANNEL = "samples.flutter.io/platform_view";
...@@ -20,10 +21,11 @@ public class MainActivity extends FlutterActivity { ...@@ -20,10 +21,11 @@ public class MainActivity extends FlutterActivity {
private MethodChannel.Result result; private MethodChannel.Result result;
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
new MethodChannel(flutterEngine.getDartExecutor(), CHANNEL).setMethodCallHandler( new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler(
new MethodChannel.MethodCallHandler() { new MethodChannel.MethodCallHandler() {
@Override @Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
......
...@@ -29,10 +29,5 @@ ...@@ -29,10 +29,5 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
package io.flutter.examples.stocks; package io.flutter.examples.stocks;
import androidx.annotation.NonNull; import android.os.Bundle;
import dev.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
@Override @Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { protected void onCreate(Bundle savedInstanceState) {
GeneratedPluginRegistrant.registerWith(flutterEngine); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment