|
|
@@ -1,4 +1,4 @@
|
|
|
-package basepedo.service;
|
|
|
+package com.xzjmyk.pm.basepedo.service;
|
|
|
|
|
|
import android.annotation.TargetApi;
|
|
|
import android.app.ActivityManager;
|
|
|
@@ -30,17 +30,17 @@ import com.xzjmyk.pm.activity.MyApplication;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.ui.MainActivity;
|
|
|
import com.xzjmyk.pm.activity.util.PreferenceUtils;
|
|
|
+import com.xzjmyk.pm.basepedo.pojo.StepData;
|
|
|
+import com.xzjmyk.pm.basepedo.ui.MyPedometerActivity;
|
|
|
+import com.xzjmyk.pm.basepedo.utils.CountDownTimer;
|
|
|
+import com.xzjmyk.pm.basepedo.utils.DbUtils;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
-import basepedo.config.Constant;
|
|
|
-import basepedo.pojo.StepData;
|
|
|
-import basepedo.ui.MyPedometerActivity;
|
|
|
-import basepedo.utils.CountDownTimer;
|
|
|
-import basepedo.utils.DbUtils;
|
|
|
+
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.CUPCAKE)
|
|
|
|
|
|
@@ -53,7 +53,7 @@ public class StepService extends Service implements SensorEventListener {
|
|
|
private static int duration = 10000;
|
|
|
private static String CURRENTDATE = "";
|
|
|
private SensorManager sensorManager;
|
|
|
- private StepDcretor stepDetector;
|
|
|
+ private com.xzjmyk.pm.basepedo.service.StepDcretor stepDetector;
|
|
|
private NotificationManager nm;
|
|
|
private NotificationCompat.Builder builder;
|
|
|
private Messenger messenger = new Messenger(new MessenerHandler());
|
|
|
@@ -63,17 +63,17 @@ public class StepService extends Service implements SensorEventListener {
|
|
|
//测试
|
|
|
private static int i = 0;
|
|
|
private String DB_NAME = "basepedo";
|
|
|
- private String uustep_service_name = "basepedo.service.StepService";
|
|
|
+ private String uustep_service_name = "com.xzjmyk.pm.basepedo.service.StepService";
|
|
|
private static class MessenerHandler extends Handler {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
switch (msg.what) {
|
|
|
- case Constant.MSG_FROM_CLIENT:
|
|
|
+ case com.xzjmyk.pm.basepedo.config.Constant.MSG_FROM_CLIENT:
|
|
|
try {
|
|
|
Messenger messenger = msg.replyTo;
|
|
|
- Message replyMsg = Message.obtain(null, Constant.MSG_FROM_SERVER);
|
|
|
+ Message replyMsg = Message.obtain(null, com.xzjmyk.pm.basepedo.config.Constant.MSG_FROM_SERVER);
|
|
|
Bundle bundle = new Bundle();
|
|
|
- bundle.putInt("step", StepDcretor.CURRENT_SETP);
|
|
|
+ bundle.putInt("step", com.xzjmyk.pm.basepedo.service.StepDcretor.CURRENT_SETP);
|
|
|
replyMsg.setData(bundle);
|
|
|
messenger.send(replyMsg);
|
|
|
} catch (RemoteException e) {
|
|
|
@@ -109,7 +109,7 @@ public class StepService extends Service implements SensorEventListener {
|
|
|
@Override
|
|
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
|
initTodayData();
|
|
|
- updateNotification("今日步数:" + StepDcretor.CURRENT_SETP + " 步");
|
|
|
+ updateNotification("今日步数:" + com.xzjmyk.pm.basepedo.service.StepDcretor.CURRENT_SETP + " 步");
|
|
|
flags = START_STICKY;
|
|
|
Log.i("StepService", "onStartCommand");
|
|
|
return super.onStartCommand(intent,flags,startId);
|
|
|
@@ -123,13 +123,13 @@ public class StepService extends Service implements SensorEventListener {
|
|
|
|
|
|
private void initTodayData() {
|
|
|
CURRENTDATE = getTodayDate();
|
|
|
- DbUtils.createDb(this, DB_NAME);
|
|
|
+ com.xzjmyk.pm.basepedo.utils.DbUtils.createDb(this, DB_NAME);
|
|
|
//获取当天的数据,用于展示
|
|
|
- List<StepData> list = DbUtils.getQueryByWhere(StepData.class, "today", new String[]{CURRENTDATE});
|
|
|
+ List<com.xzjmyk.pm.basepedo.pojo.StepData> list = com.xzjmyk.pm.basepedo.utils.DbUtils.getQueryByWhere(com.xzjmyk.pm.basepedo.pojo.StepData.class, "today", new String[]{CURRENTDATE});
|
|
|
if (list.size() == 0 || list.isEmpty()) {
|
|
|
- StepDcretor.CURRENT_SETP = 0;
|
|
|
+ com.xzjmyk.pm.basepedo.service.StepDcretor.CURRENT_SETP = 0;
|
|
|
} else if (list.size() == 1) {
|
|
|
- StepDcretor.CURRENT_SETP = Integer.parseInt(list.get(0).getStep());
|
|
|
+ com.xzjmyk.pm.basepedo.service.StepDcretor.CURRENT_SETP = Integer.parseInt(list.get(0).getStep());
|
|
|
} else {
|
|
|
Log.i(TAG, "出错了!");
|
|
|
}
|
|
|
@@ -236,7 +236,7 @@ public class StepService extends Service implements SensorEventListener {
|
|
|
.getSystemService(SENSOR_SERVICE);
|
|
|
getLock(this);
|
|
|
// android4.4以后可以使用计步传感器
|
|
|
- int VERSION_CODES = android.os.Build.VERSION.SDK_INT;
|
|
|
+ int VERSION_CODES = Build.VERSION.SDK_INT;
|
|
|
if (VERSION_CODES >= 19) {
|
|
|
addCountStepListener();
|
|
|
} else {
|
|
|
@@ -356,7 +356,7 @@ public class StepService extends Service implements SensorEventListener {
|
|
|
// android.provider.Settings.Secure.putInt(getContentResolver(), systemSettingKey,enabled ? 1 : 0);
|
|
|
// }
|
|
|
|
|
|
- synchronized private PowerManager.WakeLock getLock(Context context) {
|
|
|
+ synchronized private WakeLock getLock(Context context) {
|
|
|
if (mWakeLock != null) {
|
|
|
if (mWakeLock.isHeld())
|
|
|
mWakeLock.release();
|