我想创建一个推送通知,管理员可以在其中向所有用户发送通知。我找到了一个教程并遵循它,但它不起作用。我不确定我哪里做错了,但我得到了一个错误提示
Developer Warning for package "... " Failed to post notification on channel "null"
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String tittle = ed1.getText().toString().trim();
String subject = ed2.getText().toString().trim();
String body = ed3.getText().toString().trim();
NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notify = new Notification.Builder
(getApplicationContext()).setContentTitle(tittle).setContentText(body).
setContentTitle(subject).setSmallIcon(R.drawable.ps).build();
notify.flags |= Notification.FLAG_AUTO_CANCEL;
notif.notify(0, notify);
}
});
Run Code Online (Sandbox Code Playgroud)