Search code examples
javaandroidandroid-mediaplayer

android media player notification


I have coded up a media player which streams MP3 from a website.

With a media player such as Winamp, I can go check my email or Facebook while its playing and then go back to win-amp by using the notification window. I wanted to know if I can do something like that with my media player.

I have looked at: Android Media Player Threading ,Notifications and many more.

I goggled this concept and found a lot of confusing topics. Some people made a service while some make a foreground service and then added notification to that. I am confused on how I can make this possible. If someone can explain this concept (going from my activity class to notification bar) to me, I will be grateful. Sample code will be greatly appreciated too.


Solution

  • I found an answer to my question and decided to share with fellow novice users/students who are learning android development.

    Basically, you have to use a service side by side with your activity class if you want an effective media player. After making the service, you have to make it into a foreground service which will help you make your media player into a notification.

    If I am incorrect then please correct me. Thank you

    Sample code: http://www.java2s.com/Code/Android/Media/UsingServicetoplaymediafile.htm