New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a notification command to launch an activity #1327
Conversation
Nice! Yea that is clearly a lot easier to use then my suggestions haha. |
Looks like the checks got stuck, going to close and re-open Edit: either something is down or I am not patient enough 😆 |
var mode = data["channel"] | ||
val validModes = listOf("d", "b", "l", "w") | ||
if (mode !in validModes) | ||
mode = "d" | ||
val navigate = "google.navigation:q=$title&mode=$mode" | ||
val mapsIntentUri = Uri.parse(navigate) | ||
val mapIntent = Intent(Intent.ACTION_VIEW, mapsIntentUri) | ||
mapIntent.setPackage("com.google.android.apps.maps") | ||
mapIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK | ||
startActivity(mapIntent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we want to hard link to google navigation. Maybe use the common intent? I know it might not be identical but this way if someone doesn't use Google Maps this will still work for them.
https://developer.android.com/guide/components/intents-common#ViewMap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm ok so a special command that starts an activity with Intent.ACTION_VIEW
preset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok think i got it generic enough now lol
2ef3a99
to
64acfcc
Compare
Per: https://developer.android.com/guide/components/intents-common#Music this might also fix: #1148 as a temporary workaround until we set something up similar for actionable notifications. |
Summary
Fixes: #1326
A new command
command_activity
is added to handle this specific intent as we need to do several things to properly launch an activity. Thetitle
must contain the URI to send to the app. Thechannel
must be used to set the package name of where the intent needs to be sent to. Thegroup
must be set the intending action string. We handle generating the URI and launching the activity with the intent.Example:
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#442
Any other notes
FCM PR: home-assistant/mobile-apps-fcm-push#36