Search code examples
javaandroidannotationsandroid-annotations

Double actions in Receiver


I receive 2 action like below:

@Receiver (actions = MY_ACTION)
protected void myMethod(){
methodA();
}

@Receiver (actions = MY_ACTION_SECOND)
protected void myMethod(){
methodA();
}

Is it possible to set 2 different ACTION in 1 receiver ?


Solution

  • @Receiver accepts an array of actions:

    @Receiver(actions = {MY_ACTION, MY_ACTION_SECOND})
    void myMethod(){
        // do something
    }