I would like to know if there is a way to use the notification bar to perform some operations (onClick), without starting / resuming activity.
for example .. let's say I raise notifcation, and when the user clicks on it, instead of transferring me to some activity, it calls some regular method in my current activity / service
Is there any way to implement such a thing?
for example, the current notifcation code makes standard onClick behavior. launching an activity .. how will it bind the code to call some method instead of activity?
messagesManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.icon, message, System.currentTimeMillis()); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, someActivity.class), 0); notification.setLatestEventInfo(context, "notification", message, contentIntent); messagesManager.notify(R.string.noto, notification);
source share