当我使用Android消息2.3.063版发送彩信时,我收到了一个吐司词,上面写着“开发人员警告包com.google.android.apps.messaging”。
日志中
08-12 16:57:52.368 7661 7682 W Notification: Use of stream types is deprecated for operations other than volume control
08-12 16:57:52.368 7661 7682 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
08-12 16:57:52.369 1604 3146 E NotificationService: No Channel found for pkg=com.google.android.apps.messaging, channelId=miscellaneous, id=5, tag=null, opPkg=com.google.android.apps.messaging, callingUid=10130, userId=0, incomingUserId=0, notificationUid=10130, notification=Notification(channel=miscellaneous pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x8 color=0xff2a56c6 vis=PRIVATE)
08-12 16:57:52.375 1604 3094 D CompatibilityInfo: mCompatibilityFlags - 0
08-12 16:57:52.375 1604 3094 D CompatibilityInfo: applicationDensity - 480
08-12 16:57:52.375 1604 3094 D CompatibilityInfo: applicationScale - 1.0
08-12 16:57:52.378 7661 7682 I BugleNotifications: Notifying for tag = null, type = RESIZING_NOTIFICATION_ID, notification = Notification(channel=miscellaneous pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x8 color=0xff2a56c6 vis=PRIVATE)
08-12 16:57:52.381 7661 8893 W Notification: Use of stream types is deprecated for operations other than volume control
08-12 16:57:52.381 7661 8893 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
08-12 16:57:52.384 1604 1618 E NotificationService: No Channel found for pkg=com.google.android.apps.messaging, channelId=miscellaneous, id=5, tag=null, opPkg=com.google.android.apps.messaging, callingUid=10130, userId=0, incomingUserId=0, notificationUid=10130, notification=Notification(channel=miscellaneous pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x8 color=0xff2a56c6 vis=PRIVATE)
08-12 16:57:52.384 880 1657 W StreamHAL: Error from HAL stream in function get_presentation_position: Operation not permitted
08-12 16:57:52.387 7661 8893 I BugleNotifications: Notifying for tag = null, type = RESIZING_NOTIFICATION_ID, notification = Notification(channel=miscellaneous pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x8 color=0xff2a56c6 vis=PRIVATE)
08-12 16:57:52.390 1604 1647 E NotificationService: No Channel found for pkg=com.google.android.apps.messaging, channelId=miscellaneous, id=5, tag=null, opPkg=com.google.android.apps.messaging, callingUid=10130, userId=0, incomingUserId=0, notificationUid=10130, notification=Notification(channel=miscellaneous pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x48 color=0xff2a56c6 vis=PRIVATE)
Google Play服务版本11.3.02
Android消息2.3.063
安卓8.0.0
上面有人能帮我吗?
3条答案
按热度按时间qyswt5oh1#
正如Android文档中所述:
https://developer.android.com/preview/features/notification-channels.html
如果您以Android O为目标并在未指定有效通知通道的情况下发布通知,则无法发布通知,并且系统会记录错误。
要解决此问题,您需要创建NotificationChannel。
然后按如下方式将其分配给通知:
更新日期:
如果您想使用NotificationCompat,下面是一个简单的示例:
事实上,您必须使用Notification Builder,以便通过setChannelId()设置通道ID;
jjhzyzn02#
吐司和Logcat上的消息谈到了您应该注意的两个项目,它们的顺序是:
NotificationChannel mChannel = new NotificationChannel(id, name, importance);
builder = new NotificationCompat.Builder(this, id);
通知管理器通知管理器和通知通道mChannel也只创建一次。
通知需要设置程序:
请参阅On Android 8.1 API 27 notification does not display中的示例。
ki0zmccv3#
容易的