android - Adding onClick Action To Button In Notification -


i'm trying add button notification using custom layout. able add layout , display button. however, still can't figure out way add click listener button. here relevant code have:

codes add custom layout notification:

string ns = context.notification_service; mnotificationmanager = (notificationmanager) ctx.getsystemservice(ns); charsequence tickertext = "quick application launcher"; long when = system.currenttimemillis(); notification.builder builder = new notification.builder(ctx); notification notification=builder.getnotification(); notification.when=when; notification.tickertext=tickertext; notification.icon=r.drawable.ic_launcher;  remoteviews contentview=new remoteviews(ctx.getpackagename(), r.layout.custom_notification);  intent volume=new intent(ctx, notifactivityhandler.class); volume.putextra("do", "2"); pendingintent pvolume = pendingintent.getactivity(ctx, 1, volume, 0); contentview.setonclickpendingintent(r.id.btn2, pvolume);  notification.contentview = contentview; notification.flags |= notification.flag_ongoing_event; mnotificationmanager.notify(2345345, notification); 

this notifactivityhandler code:

public class notifactivityhandler extends activity {      private notifactivityhandler ctx;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         ctx=this;         string action= (string)getintent().getextras().get("do");         log.i("log", "lauching action: " + action);         if(action.equals("1")){         } else if(action.equals("2")){         } else if(action.equals("config")){             intent = new intent(notifactivityhandler.this, configactivity.class);             startactivity(i);         }     }    } 

codes above doesn't produce log if put log.i. i'm not sure wrong this. appreciated.

update

i tested on ics device.

you may have register listner in androidmanifest.xml. take @ this one


Comments