问题描述
我正在尝试在我的 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 (将#修改为@)