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.

dataScheme (and other) for @Receiver[Action] #1176

@dodgex

Description

@dodgex

as @ReceiverAction is now merged into develop i thought if it would make sense to add features like dataSchemes similar to @Receiver :)

the annotation would then get an String[] dataSchemes() and the generated code could be somewhat like

    public final static List<String> SAMPLE_RECEIVER_SCHEMES = Arrays.asList("http","https");
    public final static String SAMPLE_RECEIVER_ACTION = "ACTION";
    public final static String ANY_EXTRA = "EXTRA";

    @Override
    public void onReceive(Context context, Intent intent) {
        context_ = context;
        super.onReceive(context, intent);
        String action = intent.getAction();
        String scheme = intent.getScheme();
        if (SAMPLE_RECEIVER_ACTION.equals(action) && SAMPLE_RECEIVER_SCHEMES.contains(scheme)) {
            Bundle extras = intent.getExtras();
            if (extras!= null) {
                KeyEvent anyExtra = extras.getParcelable(ANY_EXTRA);
                super.sampleReceiverAction(context, anyExtra);
            }
            return ;
        }
    }

but as mentioned, i'm not yet sure if this is needed. personally i haven't used any dataScheme in a Receiver yet. but it might still be insteresting.

it this is considered usefull, maybe we should also consider adding some of the other intent filter features e.g. mime type or categories (maybe there are others too). i'm not very deep into BroadcastReceiver related stuff so i can not decide how usefull these features are but they might be usefull in other apps than mine. ;)

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