android - handling button click in notification -


i have got notification 1 button , want something, when click button of notification.

is there possibility onclicklistener handle that?

here code notification:

 private void notification_anzeigen(){       intent intent = new intent(this, gestureanywhere.class);      // string notificationmessage = "gestureanywhere läuft im hintergrund";      // intent.putextra("notificationmessage", notificationmessage);     // intent.addflags(intent.flag_activity_single_top | intent.flag_activity_clear_top);       pendingintent pintent = pendingintent.getactivity(this, 0, intent, 0);      // build notification     // addaction re-use same intent keep example short     notification n  = new notification.builder(this)             .setcontenttitle("gestureanywhere läuft im hintergrund")             //.setcontenttext("gestureanywhere muss im hintergrund ausgeführt werden, um gesten zu erkennen")             .setsmallicon(r.drawable.ic_launcher)       // muss rein, ansonsten wird keine notifikation angezeigt             .setcontentintent(pintent)             .addaction(r.drawable.ic_launcher, "plus-button", pintent)             .setstyle(new notification.bigtextstyle().bigtext("auf den plus-button drücken, um auf aktueller seite gesten zu erkennen"))             .setautocancel(true).build();      n.setlatesteventinfo(getapplicationcontext(), "plus-button", "neu", pintent);       notificationmanager notificationmanager = (notificationmanager)getsystemservice(notification_service);     notificationmanager.notify(0, n); } 

sorry question isn't clear. try specifiy little bit better:

  • i have got background service starts, when minimize application
  • when service starting, new notification shown inform user, application works in background now
  • the background service shall there in order detect gestures, drawn outside application
  • when click onto notification , application starts again, service shall stoped (otherwise can draw inside application , not click onto anymore) -> first point want do: stop background service, when click onto notification
  • when mimimize application , start service able draw onto homescreen right -> second point want do: when user click onto button under notification activity shall called in order user draw on current view

because want know how click onto notification (or button under notification) handled in don't provide code service , other stuff.

i hope question , want little bit clearer.

thanks lot.

well, understand want stop service return activity. may add inner intent of pendingintent. parse intent in activity (oncreate , onnewintent if necessary) , call context.stopservice()


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -