void DeleteSession() { Log.Info(TAG, "Deleting today's session data for speed"); var epoch = new DateTime(1970, 1, 1); var now = DateTime.UtcNow; var endTime = (now - epoch).TotalMilliseconds; var startTime = (now.Subtract(TimeSpan.FromDays(1)) - epoch).TotalMilliseconds; var request = new DataDeleteRequest.Builder() .SetTimeInterval((long)startTime, (long)endTime, TimeUnit.Milliseconds) .AddDataType(DataType.TypeSpeed) .DeleteAllSessions() .Build(); // Invoke the History API with the Google API client object and the delete request and // specify a callback that will check the result. FitnessClass.HistoryApi.DeleteData(mClient, request) .SetResultCallback((Statuses status) => { if (status.IsSuccess) { Log.Info(TAG, "Successfully deleted today's sessions"); } else { // The deletion will fail if the requesting app tries to delete data // that it did not insert. Log.Info(TAG, "Failed to delete today's sessions"); } }); }
async Task DeleteData() { Log.Info(TAG, "Deleting today's step count data"); // Set a start and end time for our data, using a start time of 1 day before this moment. DateTime endTime = DateTime.Now; DateTime startTime = endTime.Subtract(TimeSpan.FromDays(1)); long endTimeElapsed = GetMsSinceEpochAsLong(endTime); long startTimeElapsed = GetMsSinceEpochAsLong(startTime); // Create a delete request object, providing a data type and a time interval var request = new DataDeleteRequest.Builder() .SetTimeInterval(startTimeElapsed, endTimeElapsed, TimeUnit.Milliseconds) .AddDataType(DataType.TypeStepCountDelta) .Build(); // Invoke the History API with the Google API client object and delete request, and then // specify a callback that will check the result. var status = await FitnessClass.HistoryApi.DeleteDataAsync(mClient, request); if (status.IsSuccess) { Log.Info(TAG, "Successfully deleted today's step count data"); } else { // The deletion will fail if the requesting app tries to delete data // that it did not insert. Log.Info(TAG, "Failed to delete today's step count data"); } }
void DeleteData () { Log.Info (TAG, "Deleting today's step count data"); // Set a start and end time for our data, using a start time of 1 day before this moment. DateTime endTime = DateTime.Now; DateTime startTime = endTime.Subtract (TimeSpan.FromDays (1)); long endTimeElapsed = GetMsSinceEpochAsLong (endTime); long startTimeElapsed = GetMsSinceEpochAsLong (startTime); // Create a delete request object, providing a data type and a time interval var request = new DataDeleteRequest.Builder () .SetTimeInterval (startTimeElapsed, endTimeElapsed, TimeUnit.Milliseconds) .AddDataType (DataType.TypeStepCountDelta) .Build (); // Invoke the History API with the Google API client object and delete request, and then // specify a callback that will check the result. FitnessClass.HistoryApi.DeleteData (mClient, request).SetResultCallback ((Statuses status) => { if (status.IsSuccess) { Log.Info (TAG, "Successfully deleted today's step count data"); } else { // The deletion will fail if the requesting app tries to delete data // that it did not insert. Log.Info (TAG, "Failed to delete today's step count data"); } }); }
void DeleteSession () { Log.Info (TAG, "Deleting today's session data for speed"); var epoch = new DateTime (1970, 1, 1); var now = DateTime.UtcNow; var endTime = (now - epoch).TotalMilliseconds; var startTime = (now.Subtract (TimeSpan.FromDays (1)) - epoch).TotalMilliseconds; var request = new DataDeleteRequest.Builder () .SetTimeInterval ((long)startTime, (long)endTime, TimeUnit.Milliseconds) .AddDataType (DataType.TypeSpeed) .DeleteAllSessions() .Build (); // Invoke the History API with the Google API client object and the delete request and // specify a callback that will check the result. FitnessClass.HistoryApi.DeleteData (mClient, request) .SetResultCallback ((Statuses status) => { if (status.IsSuccess) { Log.Info(TAG, "Successfully deleted today's sessions"); } else { // The deletion will fail if the requesting app tries to delete data // that it did not insert. Log.Info(TAG, "Failed to delete today's sessions"); } }); }