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.

ServiceAction uses the same extra key when putting and getting action parameters #1268

@VladimirZhilyakov

Description

@VladimirZhilyakov

There is a service that implements an action with multiple parameters:

@ServiceAction
void mySimpleAction(String param1, int param2, String param3) {
    Log.i("MyService", "mySimpleAction " + param1 + " " + param2 + " " + param3);
}

Run this action with some parameters

MyService_.intent(context).mySimpleAction("1", 2, "3").start();

the output will be "mySimpleAction 3 0 3".
Generated code:

if (ACTION_MY_SIMPLE_ACTION.equals(action)) {
    Bundle extras = intent.getExtras();
    if (extras!= null) {
        String param1Extra = extras.getString(PARAM_EXTRA);  // PARAM1_EXTRA?
        int param2Extra = extras.getInt(PARAM_EXTRA);        // PARAM2_EXTRA?
        String param3Extra = extras.getString(PARAM_EXTRA);  // PARAM3_EXTRA?
        super.mySimpleAction(param1Extra, param2Extra, param3Extra);
        return ;
    }
}
...
public MyService_.IntentBuilder_ mySimpleAction(String param1, int param2, String param3) {
    action(ACTION_MY_SIMPLE_ACTION);
    super.extra(PARAM_EXTRA, param1); // PARAM1_EXTRA?
    super.extra(PARAM_EXTRA, param2); // PARAM2_EXTRA?
    super.extra(PARAM_EXTRA, param3); // PARAM3_EXTRA?
    return this;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions