binwiederhier / ntfy-android

Android app for ntfy.sh
Apache License 2.0
465 stars 92 forks source link

WIP: launch activity using broadcast intent #53

Open wunter8 opened 1 year ago

wunter8 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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