I want to implement resume and pause function running music in the background from notification bar. In my code I am using radio play from url downloaded from server. And then play audio in background. But i want to add functionality to play and pause function without open application. Thank you.
Asked
Active
Viewed 2,298 times
1
-
You need to handle the click event in the Notification bar, Please check the notificationCombat in android. – Somasundaram NP Aug 31 '15 at 12:30
-
have you any example? – Das Aug 31 '15 at 12:30
-
http://www.androidbegin.com/tutorial/android-custom-notification-tutorial/ Please check the link it will working example you need to customize it based on your requirement. – Somasundaram NP Aug 31 '15 at 12:46
-
i also used this. but when i click on notification it opens activity which we intent. i want both. – Das Aug 31 '15 at 12:53
-
You need to check how to control background service from the notification – Somasundaram NP Aug 31 '15 at 12:56
-
ya i know. but first i need click event. after that i know what i have to do. – Das Aug 31 '15 at 12:58
-
can you please check the addAction option in the android document – Somasundaram NP Aug 31 '15 at 13:00
-
ya it also open an activity. – Das Aug 31 '15 at 13:08
1 Answers
1
already asked:
Handling buttons inside android notifications
Adding onClick Action To Button In Notification
doesn't have enough reputations to add these links as a comment

Yazazzello
- 6,053
- 1
- 19
- 21
-
it's the only way to work with clicks on notification views. You create PendingIntent and assign this intent to remoteView like this: `notificationView.setOnClickPendingIntent(R.id.buttonswitch, pendingSwitchIntent);` – Yazazzello Aug 31 '15 at 12:52
-
yaeh i do. but i want both . open activity and also start stop funcation like our phone music player. understand? – Das Aug 31 '15 at 12:54
-
-
-
I was wrong, it's not necessary to add pendingintent to parent view, simply setContentIntent for notification builder and you will start activity clicking the whole notification. About child views: I've tried the first example and have no succes until register Broadcast receiver in Manifest. Does it help you, @Das ? – Yazazzello Aug 31 '15 at 14:16
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/88382/discussion-between-yazazzello-and-das). – Yazazzello Aug 31 '15 at 14:17