When practicing the message notification function with the tutorial
Discover
Notification(int icon, CharSequence tickerText, long when)
It's out of date
show deprecated
The correct way to create a Notification is as follows:
NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); Notification.Builder builder = new Notification.Builder(MainActivity.this); builder.setContentText("aaaa"); builder.setContentTitle("bbbb"); builder.setSmallIcon(R.drawable.apple); builder.setWhen(System.currentTimeMillis()); Notification notification = builder.build(); manager.notify(1,notification);