(не удалось опубликовать уведомление на канале) ошибка в Android 8 или более поздней версии - PullRequest
0 голосов
/ 26 апреля 2019

Я пытаюсь запустить ForegroundService в Android Studio с Java, я использую сервис с уведомлением.это работает очень хорошо в Android 8 ниже.но я получаю (не удалось опубликовать уведомление на канале) ошибку в Android 8 или более поздней версии.

я пишу код с этого сайта: https://codinginflow.com/tutorials/android/foreground-service

    Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
  0, notificationIntent, 0);

Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
  .setContentTitle("Example Service")
  .setContentText(input)
  .setSmallIcon(R.drawable.ic_launcher_background)
  .setContentIntent(pendingIntent)
  .build();

startForeground(1, notification);

мой код состоит в том, что коды сайта.

пожалуйста, посмотрите.

...