4
我是新的Kotlin和intentService的一点点堆栈。清单显示我的错误,我的服务不包含默认的构造函数,但内部服务看起来不错,没有错误。IntentService(kotlin)的默认构造函数
这里是我的intentService:
class MyService : IntentService {
constructor(name:String?) : super(name) {
}
override fun onCreate() {
super.onCreate()
}
override fun onHandleIntent(intent: Intent?) {
}
}
我也尝试另一种变体:
class MyService(name: String?) : IntentService(name) {
但是当我尝试运行这项服务,我还得到一个错误:
java.lang.Class<com.test.test.MyService> has no zero argument constructor
任何想法如何修复Kotlin中的默认构造函数?
谢谢!
非常感谢! –