Caused by: java.lang.IllegalArgumentException:
Service not registered: org.diql.aidldemo.MainActivity$ServiceConn@e38be65
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1044)
at android.app.ContextImpl.unbindService(ContextImpl.java:1337)
at android.content.ContextWrapper.unbindService(ContextWrapper.java:616)
at org.diql.aidldemo.MainActivity.onUnBind(MainActivity.java:45)
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
原因:
只有调用过bindService(),才可以调用unBindService(),这两个方法必须一一对应,可以只调用前者,但是绝对不能再未调用前者的情况下,调用后者,或者多次调用后者.