I am developing a WearOS app using Jetpack compose and I have one activity and multiple composable screens.
I have a requirement to launch app to two different destinations.
- User click app icon -> User will navigate to Home Screen.
- User double press the Home button ( User has customized the Home button from the watch to open the app) -> User will navigate to SOS screen.
When there is no any app instance in background or foreground, the above scenario works fine. This is my code for that ,
if (intent.action == Intent.ACTION_MAIN && intent.hasCategory(Intent.CATEGORY_LAUNCHER))
{
Screen.HomeScreen.route
}
else {
Screen.SosScreen.route
}
The problem is, when user double press the Home button(Hardware) when app is in background or foreground, it resumes the app so it can't handle using above method. How to do this in WearOS app ?. Any wearable API which I can achieve this?