美文网首页
android.app.RemoteServiceExcepti

android.app.RemoteServiceExcepti

作者: 牛年大吉2021 | 来源:发表于2024-01-28 15:06 被阅读0次

问题描述:
android.app.RemoteServiceException$CannotPostForegroundServiceNotificationException: Bad notification for startForeground。
解决方案:
8.0以上 通知 需要创建通知通道
/**
* 创建通知通道
* @param channelId
* @param channelName
* @return
*/
@RequiresApi(Build.VERSION_CODES.O)
private String createNotificationChannel(String channelId, String channelName){
NotificationChannel chan = new NotificationChannel(channelId,
channelName, NotificationManager.IMPORTANCE_NONE);
chan.setLightColor(Color.BLUE);
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
NotificationManager service = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
service.createNotificationChannel(chan);
return channelId;
}

相关文章

  • android.app.RemoteServiceExcepti

    最近终于有时间来整理一下代码 修修bug 然后发现有一样这样的问题,占据了差不多10%的安卓用户,以vivo、OP...

  • android.app.RemoteServiceExcepti

    前言 之前运行好好的app突然就不行了,启动直接crash,连接adb后发现报了这个错android.app.Re...

网友评论

      本文标题:android.app.RemoteServiceExcepti

      本文链接:https://www.haomeiwen.com/subject/dlvwodtx.html