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

Closed

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

Activity

  1. WonderCsabo commented on Feb 22, 2015

    @WonderCsabo
    Member

    Thanks for reporting! Actually we should validate that the class has no-arg constructor. I will add that and also edit the wiki.

  2. self-assigned this
    on Feb 22, 2015
  3. karlapdiaz commented on Mar 10, 2015

    @karlapdiaz

    what is the solution???

  4. regisoliveira commented on Mar 11, 2015

    @regisoliveira
    Author

    Karla,

    Please check the update documentation. The example provided is working
    correctly.
    https://github.com/excilys/androidannotations/wiki/Enhance%20IntentServices

    2015-03-10 20:49 GMT-03:00 Karla Patricia Díaz Padilla <
    notifications@github.com>:

    what is the solution???

    —
    Reply to this email directly or view it on GitHub
    #1327 (comment)
    .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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