My app plays music and when users open notifications screen by swiping from the top of the screen ( or generall from the bottom right of the screen on tablets ), i want to present them a button to stop the currently playing music and start it again if they want.
I am not planning to put a widget on user's homescreen, but just into notifications. How can i do this?
Add action button to notification
For more details visit https://developer.android.com/training/notify-user/build-notification.html
You can create an intent for the action (in this case stop playing)and that add it as an action button to your notification.
Please refer to the Android Documentation here
I will try to provide a solution that I have used and most of the music player also use the same technique to show player controls in notification bar.
I am running a service which is used to manage Media Player and all its controls. Activity User control interacts with Service by sending Intents to the service for example
TO receive intents and perform action in Service class I am using following code in onStartCommand method of Service
Now to exact answer to your question to show notification with playing controls. You can call following methods to show notification with controls.
} Hope this really helps you. And you will be able to achieve what you want. Have a Happy Coding :)
Please refer this for more details Click here