I would like to know if there is a way of using the notication bar in order to do some operations (onClick), without having an activity being launched/resumed.
for examp
Is there any way to implement such a thing?
Use an appropriate PendingIntent
. Instead of calling getActivity()
, call getService()
or getBroadcast()
.
I don't believe this is possible or, at the very least, best practice. It's possible that Android could kill your activity while the Notification is still waiting in the top bar. For example maybe you get a phone call but Android is low on RAM - it kills your activity, thus there's really not a 'current' activity anymore.