RemoteServiceException: Bad notification for startForeground 이슈

정디디·2022년 8월 16일

Android-Plus

목록 보기
3/5
post-thumbnail

이슈관련내용

notification Channel이 등록되지 않았을 경우 발생하는 오류라고 합니다.

해결방법

public void createNotificationChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager manager = getBaseContext().getSystemService(NotificationManager.class);
        NotificationChannel serviceChannel = new NotificationChannel(
                channelId,
                channelname,
                NotificationManager.IMPORTANCE_NONE
        );
        manager.createNotificationChannel(serviceChannel);
    }
}
profile
긍정적인 생각

0개의 댓글