关于Android中new Notification

时间:2023-03-09 23:38:40
关于Android中new Notification

目前 Android 已经不推荐使用下列方式创建 Notification实例:

 Notification notification = new Notification(R.drawable.ic_launcher,"This is ticker text",System.currentTimeMillis());

最好采用下列方式:

                Notification notification = new Notification.Builder(this)
.setContentTitle("This is title")
.setContentText("This is content")
.setSmallIcon(R.drawable.ic_launcher)
.setTicker("This is ticker")
.setContentIntent(pi)
.build();