IntentService 空构造函数,InstantiationException(实例化异常),java NIO

IntentService 是继承自 Service 并处理异步请求的一个类,在 IntentService 内有一个工作线程来处理耗时操作,当任务执行完后,IntentService 会自动停止,不需要我们去手动结束。如果在短时间内(Service没有自动调用stopService)启动 IntentService 多次,那么每一个耗时操作会以工作队列的方式在 IntentService 的 onHandleIntent 回调方法中执行,依次去执行,执行完自动结束。
 

报错:                   Caused by: java.lang.InstantiationException: TestIntentServer has no zero argument constructor

原因就是由于构造函数问题有参数解决:

 IntentService 的构造函数 string 什么用:

* @param name Used to name the worker thread, important only for debugging.

用于命名工作线程,仅对调试很重要。

java NIO

猜你喜欢

转载自blog.csdn.net/qq_38998213/article/details/105819561