public class HelloIntentService extends IntentService {
public HelloIntentService(String name) {
super("HelloIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
// ...
}
}
啟動 service 時發生錯誤。
java.lang.RuntimeException: Unable to instantiate service com.xxx.HelloIntentService: java.lang.InstantiationException: com.xxx.HelloIntentService瞎子摸象後找到奇怪的原因,要實作沒有參數的 constructor(No-args Constructor)。
public class HelloIntentService extends IntentService {
public HelloIntentService(String name) {
super("HelloIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
// ...
}
}
------
---
沒有留言:
張貼留言