0

I have an intentService in my app that I use to play music files in the background. In this service, I have several methods (play, pause, stop, etc.) that I need to call from my main fragment in response to UI input. However I cant seem to find any way of sending messages to an intentservice, I can only find ways to sending messages from an intentService to an activity.

If someone knows a way I can achieve this, I would much appreciate it.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
Fishingfon
  • 1,034
  • 3
  • 19
  • 33
  • 3
    [Still.....!!!!](http://stackoverflow.com/q/4300291/2389078) – DroidDev Dec 04 '14 at 08:07
  • 1
    [Did you read doc?](https://developer.android.com/training/run-background-service/send-request.html) – MysticMagicϡ Dec 04 '14 at 08:08
  • The doc for IntentService says: "Clients send requests through startService(Intent) calls". Did you try calling startService from your main fragment? – Bruce Dec 04 '14 at 08:08
  • 1
    Hi, Sorry i think i didnt explain very well. I need to be able to send messages to my running intentservice. For example, when i have started the service and it is playing a music file, i want to be able to then call a method in the service to pause the music playback in response to a button press in my main fragment. – Fishingfon Dec 04 '14 at 08:10
  • http://stackoverflow.com/q/6225157/1777090 – MysticMagicϡ Dec 04 '14 at 08:12
  • I am doing same with the link that I posted above. I used service to play music. your comment on this thread just says you haven't done enough research. That's not much of a work. Please try to read the docs and see the example that I posted above. – DroidDev Dec 04 '14 at 08:14
  • Hi, Thanks, but I am using an IntentService, not the standard Service class. Thanks anyway though, Corey – Fishingfon Dec 04 '14 at 08:14
  • DroidDev, Yes i read the link you gave, but the problem is i am using an IntentService, not a standard Service. IntentService does not use methods such as OnBind, etc. – Fishingfon Dec 04 '14 at 08:17
  • Is there any compulsion of using Intent service, if you can't do what you want with it. You can also try just using service. Sorry, if I was arrogant earlier. – DroidDev Dec 04 '14 at 08:21
  • @DroidDev, The reason i have been using IntentService is it makes handling the seperate threads, updating the ui, etc much easier (saves me having to write all the code myself). But i will have a look into using just a standard service, and whether i can do what i require with it. Thanks again for all your help, Corey B :) – Fishingfon Dec 04 '14 at 08:33

0 Answers0