flutter native method call, return to the desktop

Development xmpp found, flutter or limited functionality can not be achieved, we need to realize the function of the native

 

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 = "android/back/desktop";
    //通讯名称,回到手机桌面
    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();
            }

        });
    }


}


More Detailed Explanation:
like you can add Q group number: 913 934 649, thumbs up, comment;

Jane book: https://www.jianshu.com/u/88db5f15770d

csdn:https://me.csdn.net/beyondforme

Nuggets: https: //juejin.im/user/5e09a9e86fb9a016271294a7

Published 137 original articles · won praise 18 · views 50000 +

Guess you like

Origin blog.csdn.net/beyondforme/article/details/104054867