Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

@EIntentService Document Improvement #1327

@regisoliveira

Description

@regisoliveira

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(); 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions