0

I' developing an Android app and in this app I've got a Android MediaPlayer and I want to ask, if I can access with this MediaPlayer to a running MediaPlayer, that was started by an other app?

For example I start a song with the Android Music app and the user opens my app. Is there a method to access and control this stream of the Android Music? So I can stop the music with stop() and start it start() and all the other functions?

Squonk
  • 48,735
  • 19
  • 103
  • 135

1 Answers1

1

If you are asking if there's a way to control a Media Player running in some other app from your app, then no. There is no way to do that.

If the other app is a service though, and that service allows control over its media player through intents, then you could control the other media player, but I'd be surprised if you got that lucky.

William Morrison
  • 10,953
  • 2
  • 31
  • 48
  • Okay, and what is if this other app is my own app? in my case it is that my app starts a stream in MediaPlayer and when I close the app and want to open the app again, the stream goes on but it doesn't resume in the app, it restarts it (yes it is a bug, but I don't get a solution). and because of this bug, I want that the app doesn't create a new MediaPlayer in the onCreate() method and takes the still running stream. You know what I mean? – Dominik Dassow Aug 11 '13 at 19:56
  • I think I understand. It doesn't matter if its your app or not. If the system starts 2 of your app, you still can't communicate between them easily. Its possible but that is not a good solution here. The solution is to fix the bug causing multiple instances to run. [Check this link for help](http://stackoverflow.com/questions/9467802/how-to-enable-only-one-instance-of-my-application) – William Morrison Aug 11 '13 at 20:00
  • Okay, thank you. But the launchMode singleTask and singleInstance create a new task on launch, don't they? And this brings the same problem like a already have, doesn't it? I saw this image http://3.bp.blogspot.com/_JHMkMKLWbtQ/TRjJhg0y6TI/AAAAAAAAH3U/KJRovtfL2Ds/s1600/Untitled-1.png Or do I understand it in the wrong way? – Dominik Dassow Aug 11 '13 at 20:37