欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android中new Notification创建实例的最佳方法

程序员文章站 2024-03-07 17:25:21
目前 android 已经不推荐使用下列方式创建 notification实例: notification notification = new notifi...

目前 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();

以上所述是小编给大家介绍的android中new notification创建实例的最佳方法,希望对大家有所帮助