I am so tired when i click on download button to generate notification then show the below error. I can't understand.
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.abc:filedownloader, PID: 18839 android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x42 color=0x00000000 vis=PRIVATE) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1760)
builder = new NotificationCompat. Builder(FileDownloadHelper.getAppContext());
builder.setDefaults(Notification.DEFAULT_LIGHTS)
.setOngoing(true)
.setPriority(NotificationCompat.PRIORITY_MIN)
.setContentTitle(getTitle())
.setContentText(desc)
.setContentIntent(pendingIntent)
.setSmallIcon(R.mipmap.ic_launcher);
i replace the code to
builder = new NotificationCompat.Builder(FileDownloadHelper.getAppContext(),title); builder.setDefaults(Notification.DEFAULT_LIGHTS) .setOngoing(true) .setPriority(NotificationCompat.PRIORITY_MIN) .setContentTitle(getTitle()) .setContentText(desc) .setContentIntent(pendingIntent) .setSmallIcon(R.mipmap.ic_launcher);
User contributions licensed under CC BY-SA 3.0