Skip to content
This repository was archived by the owner on Nov 14, 2018. It is now read-only.

Add extensions for Intent creation#456

Open
hluhovskyi wants to merge 1 commit intoandroid:masterfrom
hluhovskyi:add-extensions-for-intent-creation
Open

Add extensions for Intent creation#456
hluhovskyi wants to merge 1 commit intoandroid:masterfrom
hluhovskyi:add-extensions-for-intent-creation

Conversation

@hluhovskyi
Copy link
Contributor

Make creation of intents easier. Covers #166.
In case if intent is implicit or don't require any application component:

val intent = intentOf(
    action = "action",
    data = Uri.parse(...),
    categories = setOf("category"),
    extras = bundleOf("key" to "value")
)

In case if intent should be created for specific component of application, you can use extension for Context:

val intent = context.intentFor<MyActivity>(
     action = "action",
     flags = Intent.FLAG_ACTIVITY_CLEAR_TASK,
     extras = bundleOf("key" to "value")
)

Possible parameters: action, data, type, categories, flags, extras

Concerns: in case if you need simply start activity with just one extra, it will look a bit massive

startActivity(intentFor<MyActivity>(extras = bundleOf("key" to "value")))

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants