【发布时间】:2017-04-08 10:49:18
【问题描述】:
我是 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 中的默认构造函数?
谢谢!
【问题讨论】:
标签: android kotlin intentservice android-intentservice