【问题标题】:How to i Push a Notification from android 8,9我如何从 android 8,9 推送通知
【发布时间】:2019-07-13 13:38:33
【问题描述】:

我尝试了所有代码,并尝试了谷歌的官方代码,但在我的设备和模拟器上没有任何工作

我从 YouTube 和 Google 以及许多博客获得了很多代码,但也没有任何效果

//我试试看

     NotificationManager notificationManager
 = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);    
   Notification notification = new 
Notification.Builder(MainActivity.this)

       .setContentTitle("This is a Notification")
       .setContentText("Please pay Your Attention here..!")

      .setSmallIcon(R.drawable.ic_launcher_foreground)

      .setAutoCancel(true)

       .build();
      notificationManager.notify(CHANNEL_ID1,notification);
           }
                   });

//然后尝试一下

  NotificationCompat.Builder builder = 
  new NotificationCompat.Builder(this, 
  CHANNEL_ID)

    .setSmallIcon(R.drawable.notification_icon)

    .setContentTitle(textTitle)

    .setContentText(textContent)

.setPriority(NotificationCompat.PRIORITY_DEFAULT);

//没有任何作用

代码应该在 android 8 和 9 上推送通知

如果从 android 4.4 得到太多的工作会更好

【问题讨论】:

  • 您是否收到错误、没有任何反应或其他情况?

标签: java android push-notification notifications


【解决方案1】:

在 Android O 中,必须在通知生成器中使用通道

请看这个答案https://stackoverflow.com/a/43093261/8577615

【讨论】:

  • 不,对不起,我没有任何工作
猜你喜欢
  • 2013-12-20
  • 1970-01-01
  • 1970-01-01
  • 2017-03-15
  • 2022-09-28
  • 2016-06-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多