No empty constructor when create a service

前端 未结 4 488
别跟我提以往
别跟我提以往 2020-12-01 08:40

I am struggling with this error:

08-08 11:42:53.179: E/AndroidRuntime(20288): Caused by: java.lang.InstantiationException: can\'t instantiate class co

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 09:25

    You need to add an empty constructor to your class i.e. one that takes no arguments:

    public ReminderService() {
        super("ReminderService");
    }
    

    Explanation from the documentation:

    The name is used to name the worker thread.

    NOTE: this is only applicable to intent service.

提交回复
热议问题