Skip to content

WIP: launch activity using broadcast intent#53

Open
wunter8 wants to merge 1 commit into
binwiederhier:mainfrom
wunter8:package-and-class-fields-for-broadcast-intent
Open

WIP: launch activity using broadcast intent#53
wunter8 wants to merge 1 commit into
binwiederhier:mainfrom
wunter8:package-and-class-fields-for-broadcast-intent

Conversation

@wunter8

@wunter8 wunter8 commented Mar 3, 2023

Copy link
Copy Markdown
Contributor

I don't think I'm going to finish this. Apparently when you use the android.intent.action.MAIN intent, you have to use ctx.startActivity instead of ctx.sendBroadcast. (See https://developer.android.com/reference/android/content/Intent#standard-activity-actions)

So to do it "right", I think we'd need to compare action.intent to everything in that list of standard activity actions. If it's in the list, use ctx.startActivity. If it's not in the list, use ctx.sendBroadcast. But at that point, this becomes a much bigger PR and it has only been requested once so far.

I'll just leave this code here in case we decide to pick it up again in the future.

@wunter8

wunter8 commented Mar 3, 2023

Copy link
Copy Markdown
Contributor Author

This code works for launching an app based on the given package and class, but I only tested it with the android.intent.action.MAIN intent. I didn't check or test any other cases, and I am just blindly assuming right now that if action.intent_package and action.intent_class are set, it should always use ctx.startActivity instead of ctx.sendBroadcast

@binwiederhier

Copy link
Copy Markdown
Owner

I'll just leave this code here in case we decide to pick it up again in the future.

Agreed. I do think it has been requested more than once though. But if we do it, we definitely want to do it the right way

@binwiederhier

Copy link
Copy Markdown
Owner

Is this still a valid use case? Has anyone asked for this?

@wunter8

wunter8 commented Dec 30, 2025

Copy link
Copy Markdown
Contributor Author

It comes up every once in a while. Someone just tried doing it today in binwiederhier/ntfy#1525

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants