简体   繁体   中英

Android wear: calling a “default fitness app” from java

I'm trying to have a function in my App for Android Wear to call the "default Fitness App"...
I already see in a WatchFace that it is possible tapping on an element to call the App to display a statistic of heart rate or steps count or similar.
If I change the App (for example from Google Fit to Moto Body), and I tap again on the element the new App will be started.

So it must be possible to call an action (Intent?) with some value and Android call the properly App.
I searched this "some value" but I didn't found anything. I'm sure, it exists...

Can someone help me?

Thanks a lot
Luca


After many trials and debugging other Apps, I found a solution...
I post it here in the case someone other needs it:

Intent intent = new Intent(Fitness.ACTION_VIEW, null);
intent.setType("vnd.google.fitness.data_type/com.google.heart_rate.bpm");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try
{
  startActivity(intent);
}
catch(ActivityNotFoundException e)
{
  Log.v(PROGRAM, "Unable to start Fitness App\n" + e.toString());
}

Regards
Luca

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM