I've been working on a music player app. I'm using a service to run the 
MediaPlayer. From a fragment I start the service using startService(Intent) 
and then I bound it to my activity. At least that's what I intend to do. 
The thing is that my app after getting terminated attempts to launch the 
service again and since the app is already terminated, the service throws 
an exception.

* E/ActivityThread: Activity com.veloxigami.myapplication.MainActivity has 
leaked ServiceConnection 
com.veloxigami.myapplication.MainFragment$1@d8b488c that was originally 
bound here*
*                              android.app.ServiceConnectionLeaked: 
Activity com.veloxigami.myapplication.MainActivity has leaked 
ServiceConnection com.veloxigami.myapplication.MainFragment$1@d8b488c that 
was originally bound here.*
 
My onStartCommand() is getting called 2 times. Although I've been able to 
stop the crashing message by returning *START_NOT_STICKY  *in 
onStartCommand() as it was suggested in this link 
<https://code.i-harness.com/en/q/ebcb07>. I would like to understand what 
is the actual problem here.

My project is available on my GitHub  if anyone would like to check the 
code. Music-Player-App <https://github.com/Veloxigami/MusicPlayer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/fd49ac58-93db-4991-b9c2-83210430e113%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to