While developing XMPP, it was found that the limited functions of Flutter could not be implemented, so the implementation of native functions was required

import android.os.Bundle; import io.flutter.app.FlutterActivity; import io.flutter.plugin.common.MethodChannel; import io.flutter.plugins.GeneratedPluginRegistrant; import static com.example.wechat.VideoUtils.getLocalVideoThumbnail; import static com.example.wechat.VideoUtils.getVideoThumbnail; Public class MainActivity extends FlutterActivity {private final String CHANNEL_DESKTOP = private Final String CHANNEL_DESKTOP ="android/back/desktop"; Private Final String CHANNEL_VIDEO = private Final String CHANNEL_VIDEO ="video/img";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        GeneratedPluginRegistrant.registerWith(this);
        new MethodChannel(getFlutterView(), CHANNEL_DESKTOP).setMethodCallHandler(
                (methodCall, result) -> {
                    if (methodCall.method.equals("backDesktop")) {
                        result.success(true);
                        moveTaskToBack(false);
                    } else{ result.notImplemented(); }}); new MethodChannel(getFlutterView(), CHANNEL_VIDEO).setMethodCallHandler((methodCall, result) -> {if (methodCall.method.equals("getNetVideoImg")) {
                result.success(getVideoThumbnail(methodCall.argument("path"),
                        methodCall.argument("name")));
            } else if (methodCall.method.equals("getLocalVideoImg")) {
                result.success(getLocalVideoThumbnail(methodCall.argument("path"),
                        methodCall.argument("name")));
            } else{ result.notImplemented(); }}); }}Copy the code

Jane: www.jianshu.com/u/88db5f157…

csdn:me.csdn.net/beyondforme

The Denver nuggets: juejin. Cn/user / 782508…