Android.app.RemoteServiceException: Bad Notification For StartForeground
I'm trying to start foreground service as follow: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel chan = new NotificationChannel( g
Solution 1:
Issue is happening because you are creating a channel with an ID
but sending the notification in a different ID
:
// Here, you are using the package name as channel ID
NotificationChannel chan = new NotificationChannel(
getApplicationContext().getPackageName(),
"My Foreground Service",
NotificationManager.IMPORTANCE_LOW);
// But here, you are sending notifications to "MyChannelId"
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
this, "MyChannelId");
So, I believe you just need to change Channel ID to MyChannelID
as follows:
NotificationChannel chan = new NotificationChannel(
"MyChannelId",
"My Foreground Service",
NotificationManager.IMPORTANCE_LOW);
Post a Comment for "Android.app.RemoteServiceException: Bad Notification For StartForeground"