Intent action and intent extra are interchangeable?

26 Views Asked by At

I am developing an android service. I want basically to have three state for the service: DEFAULT, FOOTASK and BARTASK. What I mean by "state" is basically that my service run some code (DEFAULT) and the user has to the option to either add a supplementary task (FOOTASK or BARTASK).

So, I was wondering if I should simply add the enum as extra and then and of course then get the extra in the service and handle it there:

AwesomeEnum awesomeEnum = intent.getSerializableExtra("AwesomeEnum");
handleEnum(awesomeEnum);

Or if it would be preferable to use intent action like:

String action = intent.getAction();
        if (action != null) {
            if(action.equals("START_FOOTASK")){
                
            }
 if(action.equals("STOP_FOOTASK")){
                
            }
                if(action.equals("START_BARTASK")){
                
            }
 if(action.equals("STOP_BARTASK")){
                
            }
0

There are 0 best solutions below