微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

颤动深层链接,错误:当我尝试将深层链接添加到我的颤动应用程序时找不到符号

如何解决颤动深层链接,错误:当我尝试将深层链接添加到我的颤动应用程序时找不到符号

我正在尝试在我的 Flutter 应用程序中实现深层链接,我关注了 This Guide 并且从我的 application.java 文件中收到了这个错误

 error: cannot find symbol

这是我的 Applicaton.java 代码


package com.deliveryrunner.vendor;

import android.content.broadcastReceiver;
import android.content.Intent;
import android.net.Uri;

import io.Flutter.app.FlutterApplication;
import io.Flutter.plugin.common.EventChannel;
import io.Flutter.plugin.common.MethodCall;
import io.Flutter.plugin.common.MethodChannel;
import io.Flutter.plugin.common.PluginRegistry;
import io.Flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.Flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

import static com.google.firebase.messaging.Constants.MessageNotificationKeys.CHANNEL;

public class Application extends FlutterApplication implements PluginRegistrantCallback {

    @Override
    public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingService.setPluginRegistrant(this);

        Intent intent = getIntent();
        Uri data = intent.getData();
        new MethodChannel(getFlutterView(),CHANNEL).setMethodCallHandler(
                new MethodChannel.MethodCallHandler() {
                    @Override
                    public void onMethodCall(MethodCall call,MethodChannel.Result result) {
                        if (call.method.equals("initialLink")) {
                            if (startString != null) {
                                result.success(startString);
                            }
                        }
                    }
                }
        );
        new EventChannel(getFlutterView(),EVENTS).setStreamHandler(
                new EventChannel.StreamHandler() {
                    @Override
                    public void onListen(Object args,final EventChannel.EventSink events) {
                        linksReceiver = createChangeReceiver(events);
                    }

                    @Override
                    public void onCancel(Object args) {
                        linksReceiver = null;
                    }
                }
        );
        if (data != null) {
            startString = data.toString();
            if (linksReceiver != null) {
                linksReceiver.onReceive(this.getApplicationContext(),intent);
            }
        }
    }
    @Override
    public void registerWith(PluginRegistry registry) {
        FirebaseCloudMessagingPluginRegistrant.registerWith(registry);
    }

    private broadcastReceiver createChangeReceiver(final EventChannel.EventSink events) {
        return new broadcastReceiver() {
            @Override
            public void onReceive(Context context,Intent intent) {
                // NOTE: assuming intent.getAction() is Intent.ACTION_VIEW

                String dataString = intent.getDataString();

                if (dataString == null) {
                    events.error("UNAVAILABLE","Link unavailable",null);
                } else {
                    events.success(dataString);
                }
            }
        };
    }

    @Override
        public void onNewIntent(Intent intent){
            super.onNewIntent(intent);
            if(intent.getAction() == android.content.Intent.ACTION_VIEW && linksReceiver != null) {
                linksReceiver.onReceive(this.getApplicationContext(),intent);
            }
        }

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。