Have you tried starting the media player in an activity, and overriding the on Back Button pressed function? Handling all the functions in the Activity Life Cycle?
I am sure there is a way to keep it running programming it in this manner! Regards, Saurav Mukherjee. On Wed, Jun 20, 2012 at 7:09 PM, Shino <shinobi...@gmail.com> wrote: > Thanks for your response. I did look there. As a matter of fact, if you > look at the first Stackoverflow > link<http://stackoverflow.com/questions/11040497/can-you-start-the-default-music-player-in-the-background>I > posted, I tried a Service for launching the music player in the > background. But it didn't work. I tried doing it two different ways... I > tried the way shown in the post where it was just a basic service that > usedSTART_STICKY, > then set the data and type of the intent and used startService. That did > nothing. I also tried using the service to launch the file as a new intent > (Activity) and that did launch the player, but it launched to the user and > hitting back or home shut it down again. I may have been doing something > wrong but if I was, I'm not sure what it is. If you can take a look at > what I did and advise what I missed, it would be appreciated. > Also... since I successfully set up an AsyncTask for downloading a file, I > thought maybe I can do that to launch the player as well. That, too, > launched the player to the user and trying to get back to my app closed it > down. > All I want to do is play the file in the default music player so that if > the user closes out of the app, the player still goes. > I could make my own player using MediaPlayer, but I'm trying to avoid that > since, as a user, I would rather it just pull up in my current music player. > > As for my other issue, I'm not sure how a Service could help my > PendingIntent from the notification communicate with an AsyncTask that is > running in the background. I still need to know how to reference it. The > other Stackoverflow > link<http://stackoverflow.com/questions/11001723/android-how-do-i-access-an-asynctask-from-a-pendingintent-created-by-a-status-b>I > posted as more detail as to what I tried there, but I tried using the > PendingIntent to launch the AsyncTask so I could access it after the user > interacted with the dialog and that was a disaster. > > > On Tuesday, June 19, 2012 2:22:40 PM UTC-4, MagouyaWare wrote: > >> The answer to both problems is most likely going to be using background >> services... So, I would start by looking here: >> >> http://developer.android.com/**guide/topics/fundamentals/**services.html<http://developer.android.com/guide/topics/fundamentals/services.html> >> >> Thanks, >> Justin Anderson >> MagouyaWare Developer >> http://sites.google.com/site/**magouyaware<http://sites.google.com/site/magouyaware> >> >> >> On Tue, Jun 19, 2012 at 8:49 AM, Shino wrote: >> >>> Hello. I'm new here and new to Android Development. >>> I'm working on my first app and it was coming along really well until I >>> ran into a couple of road blocks that I'm not sure what to do with. >>> I've done a lot of searching without any luck and I've posted questions >>> on StackOverflow but they have not been answered. I will reference them in >>> the post. >>> >>> First, I'm developing for 2.2. I am not against developing for 2.3 if >>> that may solve my issues. >>> >>> The first one is that I have 2 spots in the app where I would like to >>> launch the device's default music player and play a file (one form storage >>> and one streamed from an internet location). And that works fine, but as >>> soon as I hit back or home to try and get back to my app, the music player >>> closes and the playback stops. I did notice that if I brought down the >>> notification pane and clicked on the notification that is created, then hit >>> back, it would continue to play in the background. But having to go there >>> each time just to keep it playing is a hassle for the user. Is there >>> anyway to launch it in the background and have it keep playing. I tried >>> starting the activity in an AsyncTask too and the same thing happens >>> (Default music player shows up to the user and finishes when hitting back >>> or home). >>> More info: >>> http://stackoverflow.com/**questions/11040497/can-you-** >>> start-the-default-music-**player-in-the-background<http://stackoverflow.com/questions/11040497/can-you-start-the-default-music-player-in-the-background> >>> >>> The second issue is that I have an AsyncTask that downloads the file in >>> the background and creates a notification. When the user clicks on the >>> notification, the Activity that goes off from the PendingIntent displays a >>> dialog asking if they want to stop the download (if it's not already >>> complete). Problem here is I'm not sure how to let the AsyncTask know that >>> the task should be canceled. How do I access the AsyncTask from the >>> Activity that creates the Dialog? >>> More info: >>> http://stackoverflow.com/**questions/11001723/android-** >>> how-do-i-access-an-asynctask-**from-a-pendingintent-created-** >>> by-a-status-b<http://stackoverflow.com/questions/11001723/android-how-do-i-access-an-asynctask-from-a-pendingintent-created-by-a-status-b> >>> >>> Any assistance would be greatly appreciated. >>> These are the last 2 kinks I have to work out and I've been trying to >>> get them figured out for over a week now. I feel like I'm missing some >>> easy solution to both. >>> >>> Thanks in advance. >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To post to this group, send email to android-developers@** >>> googlegroups.com <android-developers@googlegroups.com> >>> To unsubscribe from this group, send email to >>> android-developers+**unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> >>> For more options, visit this group at >>> http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en> >> >> >> -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en