两个日志显示
1:对于音量控制以外的 *** 作,不推荐使用流类型
2:请参阅setSound()的文档,了解使用什么来代替android.media.AudioAttributes来限定播放用例
解决方法:
When you target AndroID 8.0 (API level 26), you must implement one or more notification channels to display notifications to your users.
int NOTIFICATION_ID = 234; notificationmanager notificationmanager = (notificationmanager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); if (androID.os.Build.VERSION.SDK_INT >= androID.os.Build.VERSION_CODES.O) { String CHANNEL_ID = "my_channel_01"; CharSequence name = "my_channel"; String Description = "This is my channel"; int importance = notificationmanager.importANCE_HIGH; NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance); mChannel.setDescription(Description); mChannel.enablelights(true); mChannel.setlightcolor(color.RED); mChannel.enableVibration(true); mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400}); mChannel.setShowBadge(false); notificationmanager.createNotificationChannel(mChannel); } NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, CHANNEL_ID) .setSmallicon(R.mipmap.ic_launcher) .setContentTitle(Title) .setContentText(message); Intent resultIntent = new Intent(ctx, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(ctx); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(resultPendingIntent); notificationmanager.notify(NOTIFICATION_ID, builder.build());
总结 以上是内存溢出为你收集整理的android – 无法在频道上发布通知“null”目标Api是26全部内容,希望文章能够帮你解决android – 无法在频道上发布通知“null”目标Api是26所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)