java - Error with Notification.Builder in notify -
hello new android, , 'm trying create notifications notification.builder , failed . when launching notification error
nm.notify(idnotificacionuno,notif); // error in notif
i have downloaded api 's 16 17 18 19 23, , code :
public class mainactivity extends appcompatactivity { notificationmanager nm; private static final int idnotificacionuno = 1; notification notif; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button btnlanzar = (button) findviewbyid(r.id.boton_notificacion); btnlanzar.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent = new intent(getapplicationcontext(),segundaventana.class); pendingintent intencionpendiente = pendingintent.getactivity(getapplicationcontext(),0,i,0); notification.builder notif = new notification.builder(getapplicationcontext()); notif.setsmallicon(r.drawable.tree); notif.setticker("app nature ¡tip!"); notif.setwhen(system.currenttimemillis()); notif.setcontenttitle("app nature ¡tip!"); notif.setcontenttext("cierra la llave, cuando te estes cepillando"); notif.setcontentinfo("tip"); notif.setcontentintent(intencionpendiente); nm = (notificationmanager)getsystemservice(notification_service); nm.notify(idnotificacionuno,notif); } }); }
i libraries . thank help
there ` characheter after notif.setsmallicon(r.drawable.tree); remove charachter , code run.
Comments
Post a Comment