Android requires that, when implementing of a IntentService, we create a default constructor that matches:
public IntentService(String name)
Without this constructor, AndroidAnnotation will throw an error while compiling.
Error:(15, 8) Gradle: error: constructor IntentService in class IntentService cannot be applied to given types;
required: String
found: no arguments
reason: actual and formal argument lists differ in length
Creating the constructor 'suggested' by AndroidStudio/Intellij, also doesn´t help:
Error:(13, 14) Gradle: error: constructor MyIntentService in class MyIntentService cannot be applied to given types;
required: String
found: no arguments
reason: actual and formal argument lists differ in length
I think that the example @EIntentService documentation page should consider this issue. Something like this should solve the question:
@EIntentService
public class MyIntentService extends IntentService {
//Constructor that matches IntentService´s default constructor
public MyIntentService() {
super("MyIntentService Name");
}
@ServiceAction
void mySimpleAction() {
// ...
}
@ServiceAction
void myAction(String param) {
// ...
}
@Override
protected void onHandleIntent(Intent intent) {
// Do nothing here
}
}
Also, the example that shows how to start the service should be:
MyIntentService_.intent(getApplication()) //
.myAction("test") //
.start();