AndroidX (v29): Bad notification for startForeground Error

-2

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);

android
asked on Stack Overflow Nov 19, 2019 by Afkaar • edited Nov 20, 2019 by Afkaar

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0