Something went wrong on our end
-
Peter Joseph De Jonckheere CESM2014 authoredPeter Joseph De Jonckheere CESM2014 authored
SigMotionDetect.java 10.41 KiB
package com.notificationFramework.stimulusStrategy;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.hardware.TriggerEvent;
import android.hardware.TriggerEventListener;
import android.os.IBinder;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.notificationFramework.sedentary.frontEnd.R;
import com.notificationFramework.sedentary.frontEnd.SaveFile;
import java.util.Calendar;
/**
* Created by Peter De Jonckheere on 17/01/2018.
* <p>
* The strategy which uses the significant motion sensor provided by Android in conjunction
* with the step counter sensor to determine movement and sedentary behaviour. This method is
* as accurate as the accelerometer method but requires less power as the reporting mode of
* both sensors used in this method is not as persistent as streaming. Uses the step counter in
* addition to this class as a time period for which the movement lasted was required to be
* determined.
* </p>
*/
public class SigMotionDetect extends Service implements StimulusStrategy {
/**
* The instance of the SensorManager used to handle the interfacing between the application
* and sensor hardware
*/
private SensorManager mSensorManager;
/**
* An instance of the sensor whihc will be used in this class
*/
private Sensor md;
/**
* The trigger event listener attached to the sensor
*/
private TriggerEventListener tel;
/**
* The instance of the Android OS service to handle alarms
*/
private AlarmManager am;
/**
* The previous step count as reported by the step counter sensor
*/
private float prevStepCount;
/**
* The previous timestamp of the previous report from the step counter sensor
*/
private long prevTimeStamp;
/**
* The daily record of minutes moved
*/
private int minutes;
/**
* The number of seconds moved
*/
private double seconds = 0;