flatter深度链接,错误:在尝试将深度链接添加到我的flatter应用程序时找不到符号

ybzsozfc  于 2021-06-26  发布在  Java
关注(0)|答案(0)|浏览(253)

我正试图在我的flatter应用程序中实现深度链接,我遵循了这个指南,从我的用户那里得到了这个错误 application.java 文件夹:

  1. error: cannot find symbol

下面是我的applicaton.java代码:

  1. package com.deliveryrunner.vendor;
  2. import android.content.BroadcastReceiver;
  3. import android.content.Intent;
  4. import android.net.Uri;
  5. import io.flutter.app.FlutterApplication;
  6. import io.flutter.plugin.common.EventChannel;
  7. import io.flutter.plugin.common.MethodCall;
  8. import io.flutter.plugin.common.MethodChannel;
  9. import io.flutter.plugin.common.PluginRegistry;
  10. import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
  11. import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;
  12. import static com.google.firebase.messaging.Constants.MessageNotificationKeys.CHANNEL;
  13. public class Application extends FlutterApplication implements PluginRegistrantCallback {
  14. @Override
  15. public void onCreate() {
  16. super.onCreate();
  17. FlutterFirebaseMessagingService.setPluginRegistrant(this);
  18. Intent intent = getIntent();
  19. Uri data = intent.getData();
  20. new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler(
  21. new MethodChannel.MethodCallHandler() {
  22. @Override
  23. public void onMethodCall(MethodCall call, MethodChannel.Result result) {
  24. if (call.method.equals("initialLink")) {
  25. if (startString != null) {
  26. result.success(startString);
  27. }
  28. }
  29. }
  30. }
  31. );
  32. new EventChannel(getFlutterView(), EVENTS).setStreamHandler(
  33. new EventChannel.StreamHandler() {
  34. @Override
  35. public void onListen(Object args, final EventChannel.EventSink events) {
  36. linksReceiver = createChangeReceiver(events);
  37. }
  38. @Override
  39. public void onCancel(Object args) {
  40. linksReceiver = null;
  41. }
  42. }
  43. );
  44. if (data != null) {
  45. startString = data.toString();
  46. if (linksReceiver != null) {
  47. linksReceiver.onReceive(this.getApplicationContext(), intent);
  48. }
  49. }
  50. }
  51. @Override
  52. public void registerWith(PluginRegistry registry) {
  53. FirebaseCloudMessagingPluginRegistrant.registerWith(registry);
  54. }
  55. private BroadcastReceiver createChangeReceiver(final EventChannel.EventSink events) {
  56. return new BroadcastReceiver() {
  57. @Override
  58. public void onReceive(Context context, Intent intent) {
  59. // NOTE: assuming intent.getAction() is Intent.ACTION_VIEW
  60. String dataString = intent.getDataString();
  61. if (dataString == null) {
  62. events.error("UNAVAILABLE", "Link unavailable", null);
  63. } else {
  64. events.success(dataString);
  65. }
  66. }
  67. };
  68. }
  69. @Override
  70. public void onNewIntent(Intent intent){
  71. super.onNewIntent(intent);
  72. if(intent.getAction() == android.content.Intent.ACTION_VIEW && linksReceiver != null) {
  73. linksReceiver.onReceive(this.getApplicationContext(), intent);
  74. }
  75. }
  76. }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题