intentservice no empty constructor, but there is a constructor

后端 未结 1 1410
感动是毒
感动是毒 2020-12-21 09:20

I have an IntentService within an Activity, and when I try to call the service, it throws this error, which I find strange because if I have the empty constructor declared.<

相关标签:
1条回答
  • 2020-12-21 09:28
    public class UploadService extends IntentService {
    

    Your Service is an inner class. If you want to keep it inside Activity, change it to static:

    public static class UploadService extends IntentService {
    

    You may want to read about different types of nested classes. First link from google: http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

    0 讨论(0)
提交回复
热议问题