Search code examples
androidservicebackgroundskypeforeground

Working in background


Actually, I found lots of answers for my questions but this time I am totally stuck.

My question is very easy. I am building a radio streaming application for .pls streams and when the user press the home button, I want my application to continue working. I think lots of you know ebuddy and Skype or the basic media players. They are putting themselves to notification bar and you can easily reach them from this place. I tried to create a notification for my app, but when I click the icon on the notification bar, I can't reach my app. It directly opens a new version of my app and I can't control the streaming, the initial working app is no longer existing.


Solution

  • You may want to read the descriptions for LaunchMode: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

    You want to launch your Activity as singleInstance

    Edit: maybe singleTask would be better.

    This is the workflow you want to achieve: workflow

    All background work has to be done by a service. Implementing one is quite simple, almost as creating an activity.

    There are many examples on how to do it: