Java 如何从android 8,9推送通知
我尝试了所有的代码,也尝试了谷歌的官方代码,但在我的设备和模拟器上什么都不起作用 我从YouTube、谷歌和许多博客上获得了很多代码,但都不管用 //我试试看Java 如何从android 8,9推送通知,java,android,push-notification,notifications,Java,Android,Push Notification,Notifications,我尝试了所有的代码,也尝试了谷歌的官方代码,但在我的设备和模拟器上什么都不起作用 我从YouTube、谷歌和许多博客上获得了很多代码,但都不管用 //我试试看 NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification.Builder
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_默认值)
//没用
代码应该在android 8和9上推送通知
如果在android O中从android 4.4获得太多的工作,那就更好了&必须在通知生成器中使用一个频道
请看这个答案你有错误吗?没有发生什么事吗?没有。对不起,我没办法