Closed tj1334311578 closed 6 months ago
I initialized it and printed out the corresponding resource id. The call showed a crash.
参见打印日志:E/initialize: default id:( 4130): 2131165263
log:E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): Failed to handle method call
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): java.lang.NullPointerException: Contextual Actions must contain a valid icon
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at android.app.Notification$Action$Builder.checkContextualActionNullFields(Notification.java:2092)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at android.app.Notification$Action$Builder.build(Notification.java:2108)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at androidx.core.app.NotificationCompatBuilder$Api20Impl.build(NotificationCompatBuilder.java:645)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at androidx.core.app.NotificationCompatBuilder.addAction(NotificationCompatBuilder.java:408)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at androidx.core.app.NotificationCompatBuilder.
I'm not sure what issue you're trying to describe here. The exception tells you the problem that contextual actions (emphasis on context actions) need an icon. That it's being thrown means you haven't provided one. My assumption is you think the default icon used for initialisation is to related to this and it's not as that is for the notification action
Closing as there's been no more response on this and as explained in previous message, the exception explains the cause of the issue
PlatformException(error, Contextual Actions must contain a valid icon, null, java.lang.NullPointerException: Contextual Actions must contain a valid icon D/StaticsAgent(27908): at android.app.Notification$Action$Builder.checkContextualActionNullFields(Notification.java:2092) D/StaticsAgent(27908): at android.app.Notification$Action$Builder.build(Notification.java:2108) D/StaticsAgent(27908): at androidx.core.app.NotificationCompatBuilder$Api20Impl.build(NotificationCompatBuilder.java:645) D/StaticsAgent(27908): at androidx.core.app.NotificationCompatBuilder.addAction(NotificationCompatBuilder.java:408) D/StaticsAgent(27908): at androidx.core.app.NotificationCompatBuilder.(NotificationCompatBuilder.java:112)
D/StaticsAgent(27908): at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat.java:2550)
D/StaticsAgent(27908): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:419)
D/StaticsAgent(27908): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1248)
D/StaticsAgent(27908): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1588)
D/StaticsAgent(27908): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1413)
D/StaticsAgent(27908): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
D/StaticsAgent(27908): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
D/StaticsAgent(27908): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
D/StaticsAgent(27908): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
D/StaticsAgent(27908): at android.os.Handler.handleCallback(Handler.java:942)
D/StaticsAgent(27908): at android.os.Handler.dispatchMessage(Handler.java:99)
D/StaticsAgent(27908): at android.os.Looper.loopOnce(Looper.java:201)
D/StaticsAgent(27908): at android.os.Looper.loop(Looper.java:288)
D/StaticsAgent(27908): at android.app.ActivityThread.main(ActivityThread.java:7884)
D/StaticsAgent(27908): at java.lang.reflect.Method.invoke(Native Method)
D/StaticsAgent(27908): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
D/StaticsAgent(27908): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
D/StaticsAgent(27908): )
D/StaticsAgent(27908): stack:#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
D/StaticsAgent(27908): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
D/StaticsAgent(27908):
D/StaticsAgent(27908): #2 FlutterLocalNotificationsPlugin.show (package:flutter_local_notifications/src/flutter_local_notifications_plugin.dart:240:7)
D/StaticsAgent(27908):
D/StaticsAgent(27908): #3 NotificationUtil._showNotificationWithNoSound (package:project_speed/app/utils/notification_util.dart:235:5)
D/StaticsAgent(27908):
D/StaticsAgent(27908): #4 NotificationUtil.startNotification (package:project_speed/app/utils/notification_util.dart:198:5)
D/StaticsAgent(27908):