0

I have a music service playing in background. Whenever some action happens on notification i want to listen(Pending event) those actions in service for further processing. Please provide code samples if possible.

Dhakchianandan
  • 351
  • 1
  • 6
  • 15

1 Answers1

2

You can start service on notification click by two ways :

1) First Way : You can call broadcast receiver when user clicks on notification.

For this you need to use PendingIntent.getBroadcast instead of getActivity().

Reference : How to Start one Activity and two service on notification click

2) Second Way : You can directly start service when user clicks on notification.

For this you need to use PendingIntent.getService instead of getActivity().

Reference : Start Service from Notification

Community
  • 1
  • 1
KishuDroid
  • 5,411
  • 4
  • 30
  • 47
  • I don't want to start service on notification click. I need to listen the notification click in the already running service – Dhakchianandan Nov 02 '15 at 05:45
  • @Dhakchianandan : http://stackoverflow.com/questions/22252065/refreshing-activity-on-receiving-gcm-push-notification – KishuDroid Nov 02 '15 at 05:52