首页 > 代码库 > android Service not registered

android Service not registered

Caused by: java.lang.IllegalArgumentException: Service not registered:com.broadcom.bt.app.settings.ServiceExtraSettingsActivity@414e11e0

    at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:923)

    at android.app.ContextImpl.unbindService(ContextImpl.java:1234)

    at android.content.ContextWrapper.unbindService(ContextWrapper.java:405)

    at com.broadcom.bt.app.settings.ServiceExtraSettingsActivity.onPause(ServiceExtraSettingsActivity.java:169)

    at android.app.Activity.performPause(Activity.java:5108)

    at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1225)

    at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2838)

    ... 12 more

    服务未注册,看到其他博客上是用this.getApplicationContext去获取的bindservice

    但为了保险起见,我的做法是设置一个布尔型的变量

    1、private boolean isBind = false ;

    2、isBind = bindService(svcMgrIntent, this, Context.BIND_AUTO_CREATE);

    3、if (isBind) {

    unbindService(this);

    isBind = false;

    }

 

参考网址:http://www.shangxueba.com/jingyan/1859141.html

android Service not registered