android.app.remoteserviceexception: bad notification for startforeground
See original GitHub issue#1234 Hi Exoplayer Team, I am getting errors with the latest version 2.15.1 when trying to show notifications in the notification tray. Why is this issue here? I am using the following code.
notificationManager = new PlayerNotificationManager
.Builder(this, NOTIFICATION_ID, PLAYBACK_ID)
.setMediaDescriptionAdapter(mediaDescriptionAdapter)
// .setChannelNameResourceId(2)
// .setChannelDescriptionResourceId(2)
.setNotificationListener(notificationListener)
.build();
and in the notificationlistener my code is
private final PlayerNotificationManager.NotificationListener notificationListener =
new PlayerNotificationManager.NotificationListener() {
@Override
public void onNotificationCancelled(int notificationId, boolean dismissedByUser) {
if (dismissedByUser) {
stopSelf();
}
}
@Override
public void onNotificationPosted(int notificationId, @NotNull Notification notification, boolean ongoing) {
Toast.makeText(getApplicationContext(), "n " + notificationId, Toast.LENGTH_SHORT).show();
if (!ongoing) {
stopForeground(true);
} else {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// startForeground(notificationId, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
// } else {
// startForeground(notificationId, notification);
// }
}
}
};
the notification listener code works well in android 11 1 yeat back when I think I am using the 2.10.0 version, but now I think the issue is in android 11 only because of check-in version 9 and it works well. Please help me to fix it for my app because I have to publish an update of the app next week.
Hope you understand and help me to find out
Android Device - Redmi Note10S Android Version - 11
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
startForeground fail after upgrade to Android 8.1
After some tinkering for a while with different solutions i found out that one must create a notification channel in Android 8.1 and...
Read more >Bad notification for startForeground crash on >= Android 8.1 ...
FATAL EXCEPTION: main android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel ...
Read more >A bug in Android 9 allows app to start a foreground service ...
When app passes bad notification to the startForeground API, crash the app and DO NOT let app start foreground service, like all Android...
Read more >Bad notification for startForeground: java.lang ... - 51CTO博客
android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException,安卓开发8.1以上系统启动服务和通知报错 ...
Read more >Bad notification for startForeground: java.lang.RuntimeException
[Android] android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I marked this as a
documentation candidate
to document the constructor argumentchannelId
in more detail/. It should say that the channel needs to be already created or elsesetChannelNameResourceId
needs to be called.Closing this issue as the need for an existing channel has been documented and there wasn’t any more activity. Please reopen if this is still an issue.