Here's pedometer sample for UWP. It works fine on my phone.
However, in my custom app, I cannot get it to determine whether the pedometer device can be accessed. It always gives me DeviceAccessStatus.Unspecified status.
Here's the standard code:
// Common class ID for pedometers
Guid PedometerClassId = new Guid("B19F89AF-E3EB-444B-8DEA-202575A71599");
// Determine if we can access pedometers
var deviceAccessInfo = DeviceAccessInformation.CreateFromDeviceClassId(PedometerClassId);
if (deviceAccessInfo.CurrentStatus == DeviceAccessStatus.Allowed)
{}
What I may be missing here, guys? Same happens on device that supports Pedometer and on one that doesn't.
I've compared both project manifest files, etc.
If I skip this check, then later on I get Access denied exception when trying to run viewModel.Pedometer = await Pedometer.GetDefaultAsync();.
Have you specified the
Devicecapability in thePackage.appxmanifest?It is present in the sample's manifest (line 58), it is probably required to be able to access the device. The
AccessDeniedExceptionseems to support this.