java - Android Notification and NoSuchMethodError -


i build notification:

notification.builder builder = new notification.builder(                             getapplicationcontext())                             .setticker(                                     getapplicationcontext().getstring(                                             r.string.my_string))                             .setsmallicon(android.r.drawable.sym)                             .setcontenttitle(                                     getapplicationcontext().getstring(                                             r.string.my_string_two))                             .setcontenttext(a.getb())                             .setsound(                                     ringtonemanager                                             .getdefaulturi(ringtonemanager.type_notification))                             .setvibrate(new long[] { 10001000 })                             .setautocancel(true)                             .setcontentintent(pendingintent.getactivity(getapplicationcontext(),0,                                                     new intent()                                                             .setaction(intent.action_view)                                                             .settype(calllog.calls.content_type)                                                             .addflags(intent.flag_activity_new_task),                                                     0));                     notificationmanager nm = (notificationmanager) getapplicationcontext()                             .getsystemservice(context.notification_service);                     nm.notify("interstitial_tag", 1, builder.build()); 

with android 4.0 i've found error: nosuchmethoderror. how can solve it? use notification.compact? thank you.

can try:

public static void sendnotification(context context, string info){         notificationcompat.builder notifybuilder = new notificationcompat.builder(context); //title notifications notifybuilder.setcontenttitle(context.getstring(r.string.app_name)); //small icon notifybuilder.setsmallicon(r.drawable.ic_launcher); //set contenttext notifybuilder.setcontenttext(info); notifybuilder.setvibrate(new long[]{100, 200, 100, 500});       notifybuilder.setsound(ringtonemanager.getdefaulturi(ringtonemanager.type_notification)); //setautocancel notifybuilder.setautocancel(true);  getnotificationmanager(context).notify(0, notifybuilder.build()); }  public final static notificationmanager getnotificationmanager(context context) { return (notificationmanager)context.getsystemservice(context.notification_service); } 

and when used new intent(), please insert destination class

intent wrapperintent = new intent(context, senderbroadcast.class); wrapperintent.putextra("key_uid", uid); wrapperintent.setdata(uri.parse("senderbroadcast://"+uid)); wrapperintent.setaction("requestcode_senderbroadcast"); pendingintent.getactivity(context, requestcode.requestcode_senderbroadcast, wrapperintent, pendingintent.flag_update_current); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -