Back to project page RazorRunner-AndroidProject.
The source code is released under:
Apache License
If you think the Android project RazorRunner-AndroidProject listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package edu.uark.csce.razorrunner; /*w w w .j ava 2 s . c o m*/ import android.content.SharedPreferences; /** * Created by Kai Tribble on 12/3/2014. */ public class PedometerSettings { SharedPreferences mSettings; public static int M_NONE = 1; public PedometerSettings(SharedPreferences settings) { mSettings = settings; } public boolean isMetric() { return mSettings.getString("units", "imperial").equals("metric"); } public float getStepLength() { try { return Float.valueOf(mSettings.getString("step_length", "20").trim()); } catch (NumberFormatException e) { // TODO: reset value, & notify user somehow return 0f; } } public float getBodyWeight() { try { return Float.valueOf(mSettings.getString(ActivityUtils.WEIGHT, "50").trim()); } catch (NumberFormatException e) { // TODO: reset value, & notify user somehow return 0f; } } public boolean wakeAggressively() { return mSettings.getString("operation_level", "run_in_background").equals("wake_up"); } public boolean keepScreenOn() { return mSettings.getString("operation_level", "run_in_background").equals("keep_screen_on"); } public boolean isRunning() { return mSettings.getString(ActivityUtils.KEY_PREVIOUS_ACTIVITY_TYPE, "running").equals("running"); } // // Internal public void saveServiceRunningWithTimestamp(boolean running) { SharedPreferences.Editor editor = mSettings.edit(); editor.putBoolean("service_running", running); editor.putLong("last_seen", ActivityUtils.currentTimeInMillis()); editor.commit(); } public void saveServiceRunningWithNullTimestamp(boolean running) { SharedPreferences.Editor editor = mSettings.edit(); editor.putBoolean("service_running", running); editor.putLong("last_seen", 0); editor.commit(); } public void clearServiceRunning() { SharedPreferences.Editor editor = mSettings.edit(); editor.putBoolean("service_running", false); editor.putLong("last_seen", 0); editor.commit(); } public boolean isServiceRunning() { return mSettings.getBoolean("service_running", false); } public boolean isNewStart() { // activity last paused more than 10 minutes ago return mSettings.getLong("last_seen", 0) < ActivityUtils.currentTimeInMillis() - 1000*60*10; } }