有人可以告诉我一个IntentService可以用a无法完成的事情的例子Service(反之亦然)吗?
我也相信IntentService在不同的线程中运行而Service不是.所以,据我所知,在自己的线程中启动服务就像开始一样IntentService.不是吗?
如果有人可以帮我解决我的两个问题,我将不胜感激.
multithreading android android-service android-intentservice
我有一个绑定到应用程序上下文的服务,如下所示:
getApplicationContext().bindService(
new Intent(this, ServiceUI.class),
serviceConnection,
Context.BIND_AUTO_CREATE
);
protected void onDestroy() {
super.onDestroy();
getApplicationContext().unbindService(serviceConnection);
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,有时只有应用程序上下文没有正确绑定(我无法修复该部分),但是在onDestroy()中我做了unbindservice哪个会抛出错误
java.lang.IllegalArgumentException: Service not registered: tools.cdevice.Devices$mainServiceConnection.
Run Code Online (Sandbox Code Playgroud)
我的问题是:unbindservice在解除绑定之前,有没有办法安全地打电话或检查它是否已绑定到服务?
提前致谢.
任何人都可以解释android中的未绑定和绑定服务之间的区别,并解释有意服务
谢谢