Android unable to destroy activity service not registered activity itself -


i'm making mp3 player uses service able play music when phone closed or app minimized. however, when go add playlist activity , try main activity, following error message:

 java.lang.runtimeexception: unable destroy activity {dv606.mp3player/dv606.mp3player.mp3player}:  java.lang.illegalargumentexception: service not registered:  dv606.mp3player.mp3player$6@6ea6ce6 

which confuses me since says main activity service not. "musicservice" separate class.

i use following way close main activity:

@override protected void ondestroy() {     super.ondestroy();     appterminated(isbound, connection); } 

appterminated:

public static void appterminated(boolean b, serviceconnection c) {     if (b && c != null && musicservice != null) {         musicservice.unbindservice(c);     } } 

connection obtained follows:

public static serviceconnection connection = new serviceconnection() {     @override     public void onserviceconnected(componentname name, ibinder service) {         musicservice = ((musicservice.musicbinder) service).getservice();     }      @override     public void onservicedisconnected(componentname name) {         musicservice = null;     } }; 

isbound this:

isbound = bindservice(intentt, connection, context.bind_auto_create); 

in music service class have these 2 methods well:

@override public void ontaskremoved(intent rootintent) {     super.ontaskremoved(rootintent);     mp3player.appterminated(mp3player.isbound, mp3player.connection); }  @override public void ondestroy() {     super.ondestroy();     mp3player.appterminated(mp3player.isbound, mp3player.connection); } 

i totally @ loss here, both because of error message , because thought way implement, bind , unbind service main activity.

i guess wrong somewhere.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -