コード例 #1
0
    void Awake()
    {
        //dropdown.ClearOptions();
        List <string> opts = new List <string>();

        for (int i = 0; i <= (int)HKDataType.HKQuantityTypeIdentifierUVExposure; i++)
        {
            HKDataType dataType = (HKDataType)i;
            opts.Add(HealthKitDataTypes.GetIdentifier(dataType));
        }

        opts.Add("———");

        for (int i = (int)HKDataType.HKCharacteristicTypeIdentifierBiologicalSex; i <= (int)HKDataType.HKCharacteristicTypeIdentifierWheelchairUse; i++)
        {
            HKDataType dataType = (HKDataType)i;
            opts.Add(HealthKitDataTypes.GetIdentifier(dataType));
        }

        opts.Add("———");

        for (int i = (int)HKDataType.HKCorrelationTypeIdentifierBloodPressure; i <= (int)HKDataType.HKCorrelationTypeIdentifierFood; i++)
        {
            HKDataType dataType = (HKDataType)i;
            opts.Add(HealthKitDataTypes.GetIdentifier(dataType));
        }

        opts.Add("———");

        opts.Add(HealthKitDataTypes.GetIdentifier(HKDataType.HKWorkoutTypeIdentifier));

        //dropdown.AddOptions(opts);
    }
コード例 #2
0
    // reading a Characteristic
    private void ReadCharacteristic(HKDataType dataType)
    {
        string typeName = HealthKitDataTypes.GetIdentifier(dataType);

        Debug.LogFormat("reading {0}", typeName);
        this.healthStore.ReadCharacteristic(dataType, delegate(Characteristic characteristic) {
            Debug.Log("FINISHED");
            string text            = string.Format("{0} = {1}", dataType, characteristic);
            this.resultsLabel.text = text;

            // all done
            reading = false;
        });
    }
コード例 #3
0
    // A basic example of reading Quantity data.
    private void ReadQuantityData(HKDataType dataType, DateTimeOffset start, DateTimeOffset end)
    {
        string typeName = HealthKitDataTypes.GetIdentifier(dataType);

        Debug.LogFormat("reading {0} from {1} to {2}", typeName, start, end);
        double sum = 0;

        this.healthStore.ReadQuantitySamples(dataType, start, end, delegate(List <QuantitySample> samples) {
            if (samples.Count > 0)
            {
                Debug.Log("found " + samples.Count + " samples");
                bool cumulative = (samples[0].quantityType == QuantityType.cumulative);
                string text     = "";
                foreach (QuantitySample sample in samples)
                {
                    Debug.Log("   - " + sample);
                    if (cumulative)
                    {
                        sum += Convert.ToInt32(sample.quantity.doubleValue);
                    }
                    else
                    {
                        text = text + "- " + sample + "\n";
                    }
                }

                if (cumulative)
                {
                    if (sum > 0)
                    {
                        this.resultsLabel.text = typeName + ":" + sum;
                    }
                }
                else
                {
                    this.resultsLabel.text = text;
                }
            }
            else
            {
                Debug.Log("found no samples");
            }


            // all done
            reading = false;
        });
    }
コード例 #4
0
    /*! @brief        Searches for HealthKitDataTypes objects & reads the usage strings for the OnPostprocessBuild phase.
     *      @param scene  the scene being processed.
     */
    public void OnProcessScene(Scene scene)
    {
        GameObject[] rootObjects = scene.GetRootGameObjects();
        foreach (GameObject obj in rootObjects)
        {
            HealthKitDataTypes types = obj.GetComponentInChildren <HealthKitDataTypes>();
            if (types != null)
            {
                if (types.AskForSharePermission())
                {
                    this.shareString = types.healthShareUsageDescription;
                }

                if (types.AskForUpdatePermission())
                {
                    this.updateString = types.healthUpdateUsageDescription;
                }
            }
        }
    }
コード例 #5
0
 public HealthKitService(HealthStore healthStore, HealthKitDataTypes healthKitDataTypes)
 {
     this.healthStore        = healthStore;
     this.healthKitDataTypes = healthKitDataTypes;
 }