I’m developing an Android application in Kotlin that connects to an ESP device to extract data from fitness equipment that we’re still building. I want to trigger an Intent that takes the user to the Exercise screen in Samsung Health as soon as they connect to the machine.
I found a forum post where someone was able to open the step report using the URI: health://steps
.
Is it possible to do the same for the Exercise screen? Additionally, can I specify a particular exercise, such as a treadmill or bike, when launching it?
Hey titio_ackerman,
Can you please provide the forum post you are referring to.
I was only able to launch Home Activity from the app. The URI you’ve shown is not working.
Here is how I’ve launched the MainActivity:
private fun launchSamsungHealth() {
val packageName = "com.sec.android.app.shealth"
val intent = packageManager.getLaunchIntentForPackage(packageName)
if (intent != null)
startActivity(intent)
else
Toast.makeText(applicationContext, "intent not found", Toast.LENGTH_SHORT).show()
}
And this is how I tried to launch via the URI:
private fun launchViaURI() {
val intentURI = "health://steps"
try {
intent = Intent.parseUri(intentURI, Intent.URI_INTENT_SCHEME)
startActivity(intent)
} catch (e: URISyntaxException) {
e.printStackTrace()
}
}
Let me know if I should change my approach.
Regards,
Imrul
Hello imrulanwar836, How are you?
Thank you for your response! Yes, your method works as long as I change the packageName
to "com.samsung.android.wear.shealth"
, since the application will run on a smartwatch. However, my issue is that I am unable to access the exercise screen.
In the example you provided using:
private fun launchSamsungHealth() {
val packageName = "com.samsung.android.wear.shealth"
val intent = packageManager.getLaunchIntentForPackage(packageName)
if (intent != null)
startActivity(intent)
else
Toast.makeText(applicationContext, "Intent not found", Toast.LENGTH_SHORT).show()
}
This is correct because I can open the MainActivity of Samsung Health.
My only issue is that I don’t know how to directly open the Exercise screen in Samsung Health, just like what happens when using the URI "health://steps"
, as you demonstrated in the following code:
private fun launchViaURI() {
val intentURI = "health://steps"
try {
intent = Intent.parseUri(intentURI, Intent.URI_INTENT_SCHEME)
startActivity(intent)
} catch (e: URISyntaxException) {
e.printStackTrace()
}
}
I tried executing a similar approach, such as "health://exercise"
, but I still couldn’t directly access the Exercise screen in Samsung Health.
I’m developing an application that will connect to an ESP32, which I plan to integrate with fitness devices such as a treadmill or stationary bike. For this reason, I would like to open the Exercise screen in Samsung Health as soon as the application connects to the machine so that it can start tracking the workout automatically.
Thank you for your attention!
Hi titio_ackerman,
Did “health://steps” URI work? For me it didn’t.
Regards,
Imrul
Hello, @imrulanwar836!
Here is the post in question. Please keep in mind that I have only tested this on the Samsung Galaxy Watch 4, and it worked fine for me. My question is: how do I access the exercise screen?