Commit b8ae70386a3428c337a95c4b994a196ea98dc9fe

Authored by 杨帅
1 parent a90484e2

1 修复BUG

app/src/main/java/com/example/modulepedometer/MainActivity.java
@@ -31,8 +31,8 @@ public class MainActivity extends AppCompatActivity { @@ -31,8 +31,8 @@ public class MainActivity extends AppCompatActivity {
31 super.onCreate(savedInstanceState); 31 super.onCreate(savedInstanceState);
32 setContentView(R.layout.activity_main); 32 setContentView(R.layout.activity_main);
33 33
34 -// String uid = "10535072";  
35 - String uid = "358916"; 34 + String uid = "10535072";
  35 +// String uid = "358916";
36 // String uid = "358689"; 36 // String uid = "358689";
37 37
38 findViewById(R.id.recordd).setOnClickListener(new View.OnClickListener() { 38 findViewById(R.id.recordd).setOnClickListener(new View.OnClickListener() {
config.gradle
@@ -21,7 +21,7 @@ ext { @@ -21,7 +21,7 @@ ext {
21 //编译方式 21 //编译方式
22 debug : false, 22 debug : false,
23 //版本号 23 //版本号
24 - version: "0.6.21", 24 + version: "0.7.0",
25 //Lib库前缀 25 //Lib库前缀
26 packeg : "com.cnlive.module", 26 packeg : "com.cnlive.module",
27 //Lib库名称 27 //Lib库名称
moudle_pedometer/src/main/AndroidManifest.xml
@@ -52,36 +52,46 @@ @@ -52,36 +52,46 @@
52 android:required="true" /> 52 android:required="true" />
53 53
54 <application android:persistent="true"> 54 <application android:persistent="true">
55 - <activity android:name="com.cnlive.moudle.collectionTrace.ui.activity.RaceNameListActivity" 55 + <activity
  56 + android:name="com.cnlive.moudle.collectionTrace.ui.activity.RaceNameListActivity"
56 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 57 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
57 - android:screenOrientation="portrait"/>  
58 - <activity android:name="com.cnlive.moudle.collectionTrace.ui.activity.RaceListActivity" 58 + android:screenOrientation="portrait" />
  59 + <activity
  60 + android:name="com.cnlive.moudle.collectionTrace.ui.activity.RaceListActivity"
59 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 61 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
60 - android:screenOrientation="portrait"/>  
61 - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.LineUpAgainActivity" 62 + android:screenOrientation="portrait" />
  63 + <activity
  64 + android:name="com.cnlive.moudle.pedometer.ui.activity.LineUpAgainActivity"
62 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 65 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
63 - android:screenOrientation="portrait"/>  
64 - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.SelfRecordActivity" 66 + android:screenOrientation="portrait" />
  67 + <activity
  68 + android:name="com.cnlive.moudle.pedometer.ui.activity.SelfRecordActivity"
65 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 69 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
66 - android:screenOrientation="portrait"/>  
67 - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.TakePartActivity" 70 + android:screenOrientation="portrait" />
  71 + <activity
  72 + android:name="com.cnlive.moudle.pedometer.ui.activity.TakePartActivity"
68 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 73 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
69 - android:screenOrientation="portrait"/>  
70 - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RunLineActivity" 74 + android:screenOrientation="portrait" />
  75 + <activity
  76 + android:name="com.cnlive.moudle.pedometer.ui.activity.RunLineActivity"
71 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 77 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
72 - android:screenOrientation="portrait"/>  
73 - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.MyRecordActivity" 78 + android:screenOrientation="portrait" />
  79 + <activity
  80 + android:name="com.cnlive.moudle.pedometer.ui.activity.MyRecordActivity"
74 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 81 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
75 - android:screenOrientation="portrait"/>  
76 - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.ShareRecordActivity" 82 + android:screenOrientation="portrait" />
  83 + <activity
  84 + android:name="com.cnlive.moudle.pedometer.ui.activity.ShareRecordActivity"
77 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 85 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
78 - android:screenOrientation="portrait"/>  
79 - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity" 86 + android:screenOrientation="portrait" />
  87 + <activity
  88 + android:name="com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity"
80 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 89 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
81 - android:screenOrientation="portrait"/>  
82 - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity" 90 + android:screenOrientation="portrait" />
  91 + <activity
  92 + android:name="com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity"
83 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 93 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
84 - android:screenOrientation="portrait"/> 94 + android:screenOrientation="portrait" />
85 95
86 <service 96 <service
87 android:name="com.cnlive.moudle.pedometer.service.StepService" 97 android:name="com.cnlive.moudle.pedometer.service.StepService"
@@ -183,7 +193,7 @@ @@ -183,7 +193,7 @@
183 android:enabled="true" 193 android:enabled="true"
184 android:exported="true" 194 android:exported="true"
185 android:priority="1000" 195 android:priority="1000"
186 - android:process=":re" /> 196 + android:process=":alive" />
187 <service 197 <service
188 android:name="com.cnlive.moudle.collectionTrace.service.CollStepService" 198 android:name="com.cnlive.moudle.collectionTrace.service.CollStepService"
189 android:enabled="true" 199 android:enabled="true"
@@ -221,22 +231,27 @@ @@ -221,22 +231,27 @@
221 <activity 231 <activity
222 android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity" 232 android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity"
223 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 233 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  234 + android:launchMode="singleTask"
224 android:screenOrientation="portrait" /> 235 android:screenOrientation="portrait" />
225 <activity 236 <activity
226 android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity" 237 android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity"
227 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 238 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  239 + android:launchMode="singleTask"
228 android:screenOrientation="portrait" /> <!-- android:theme="@style/Theme.AppCompat.Light.NoActionBar" --> 240 android:screenOrientation="portrait" /> <!-- android:theme="@style/Theme.AppCompat.Light.NoActionBar" -->
229 <activity 241 <activity
230 android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunningMapActivity" 242 android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunningMapActivity"
231 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 243 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  244 + android:launchMode="singleTask"
232 android:screenOrientation="portrait" /> 245 android:screenOrientation="portrait" />
233 <activity 246 <activity
234 android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunRaceDetailActivity" 247 android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunRaceDetailActivity"
235 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 248 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  249 + android:launchMode="singleTask"
236 android:screenOrientation="portrait" /> 250 android:screenOrientation="portrait" />
237 <activity 251 <activity
238 android:name="com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity" 252 android:name="com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity"
239 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" 253 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  254 + android:launchMode="singleTask"
240 android:screenOrientation="portrait" /> 255 android:screenOrientation="portrait" />
241 </application> 256 </application>
242 257
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
@@ -534,7 +534,6 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -534,7 +534,6 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
534 mLocClient = new LocationClient(getContext()); 534 mLocClient = new LocationClient(getContext());
535 mLocClient.registerLocationListener(myListener); 535 mLocClient.registerLocationListener(myListener);
536 LocationClientOption option = new LocationClientOption(); 536 LocationClientOption option = new LocationClientOption();
537 - option.setOpenGps(true); // 打开gps  
538 //可选,设置返回经纬度坐标类型,默认GCJ02 537 //可选,设置返回经纬度坐标类型,默认GCJ02
539 //GCJ02:国测局坐标; 538 //GCJ02:国测局坐标;
540 //BD09ll:百度经纬度坐标; 539 //BD09ll:百度经纬度坐标;
@@ -551,11 +550,11 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -551,11 +550,11 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
551 //LocationMode. Device_Sensors:仅使用设备; 550 //LocationMode. Device_Sensors:仅使用设备;
552 option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); 551 option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
553 //可选,设置是否需要地址信息,默认不需要 552 //可选,设置是否需要地址信息,默认不需要
554 - option.setIsNeedAddress(true); 553 + option.setIsNeedAddress(false);
555 //可选,设置是否需要地址描述 554 //可选,设置是否需要地址描述
556 - option.setIsNeedLocationDescribe(true); 555 + option.setIsNeedLocationDescribe(false);
557 //需要POI信息 556 //需要POI信息
558 - option.setIsNeedLocationPoiList(true); 557 + option.setIsNeedLocationPoiList(false);
559 //可选,设置是否需要设备方向结果 558 //可选,设置是否需要设备方向结果
560 option.setNeedDeviceDirect(false); 559 option.setNeedDeviceDirect(false);
561 //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者 560 //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者
@@ -604,6 +603,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -604,6 +603,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
604 if (location == null || mMapView == null || getContext() == null) { 603 if (location == null || mMapView == null || getContext() == null) {
605 return; 604 return;
606 } 605 }
  606 +
607 //正在搜索GPS信号 607 //正在搜索GPS信号
608 if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_UNKNOWN) { 608 if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_UNKNOWN) {
609 if (fragment.binding.tvGpsPopBg.getVisibility() != View.VISIBLE) { 609 if (fragment.binding.tvGpsPopBg.getVisibility() != View.VISIBLE) {
@@ -653,9 +653,9 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -653,9 +653,9 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
653 fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3)); 653 fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3));
654 } 654 }
655 } 655 }
656 -// if (followMyLocation == null || followMyLocation.latitude == 0 || followMyLocation.longitude == 0) {  
657 -// return;  
658 -// } 656 + if (followMyLocation == null || followMyLocation.latitude == 0 || followMyLocation.longitude == 0) {
  657 + return;
  658 + }
659 MapStatus.Builder builder = new MapStatus.Builder(); 659 MapStatus.Builder builder = new MapStatus.Builder();
660 mCurrentAccracy = location.getRadius(); 660 mCurrentAccracy = location.getRadius();
661 followMyLocation = new MyLocationData.Builder() 661 followMyLocation = new MyLocationData.Builder()
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
@@ -8,6 +8,7 @@ import android.hardware.Sensor; @@ -8,6 +8,7 @@ import android.hardware.Sensor;
8 import android.hardware.SensorEvent; 8 import android.hardware.SensorEvent;
9 import android.hardware.SensorEventListener; 9 import android.hardware.SensorEventListener;
10 import android.hardware.SensorManager; 10 import android.hardware.SensorManager;
  11 +import android.os.Build;
11 import android.support.v4.content.ContextCompat; 12 import android.support.v4.content.ContextCompat;
12 import android.text.TextUtils; 13 import android.text.TextUtils;
13 import android.util.Log; 14 import android.util.Log;
@@ -156,7 +157,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -156,7 +157,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
156 */ 157 */
157 public void checkIsHasRunningRace() { 158 public void checkIsHasRunningRace() {
158 //先判断有没有数据 159 //先判断有没有数据
159 - CollUserStepEntity userStepEntity = CollStepUtil.getCollUserStepData(getContext(), CommonInfo.getUserId(getContext())); 160 + CollUserStepEntity userStepEntity = CollStepUtil.getCollUserStepData(getContext(), CollCommonInfo.getUserId(getContext()));
160 if (null != userStepEntity) { 161 if (null != userStepEntity) {
161 //判断用户是否点击wanc 162 //判断用户是否点击wanc
162 if (0 == userStepEntity.getFinishTimeStamp()) { 163 if (0 == userStepEntity.getFinishTimeStamp()) {
@@ -259,7 +260,11 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -259,7 +260,11 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
259 CollCommonInfo.setTsRunBaiduTraceService(context, true); 260 CollCommonInfo.setTsRunBaiduTraceService(context, true);
260 CollCommonInfo.setIsWriteUserStep(context, true); 261 CollCommonInfo.setIsWriteUserStep(context, true);
261 Intent intent = new Intent(fragment.getActivity(), CollKeepLiveService.class); 262 Intent intent = new Intent(fragment.getActivity(), CollKeepLiveService.class);
262 - ContextCompat.startForegroundService(fragment.getActivity(), intent); 263 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  264 + fragment.getActivity().startForegroundService(intent);
  265 + } else {
  266 + fragment.getActivity().startService(intent);
  267 + }
263 268
264 } 269 }
265 270
@@ -448,7 +453,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -448,7 +453,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
448 MapStatus.Builder builder = new MapStatus.Builder(); 453 MapStatus.Builder builder = new MapStatus.Builder();
449 builder.target(new LatLng(followMyLocation.latitude, followMyLocation.longitude)).zoom(DEFULT_ZOOM); 454 builder.target(new LatLng(followMyLocation.latitude, followMyLocation.longitude)).zoom(DEFULT_ZOOM);
450 baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); 455 baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
451 - isFollowUserShow=false; 456 + isFollowUserShow = false;
452 } 457 }
453 } 458 }
454 // if (location.hasAddr()) { 459 // if (location.hasAddr()) {
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/receivers/CollServiceReceiver.java
@@ -23,7 +23,7 @@ public class CollServiceReceiver extends BroadcastReceiver { @@ -23,7 +23,7 @@ public class CollServiceReceiver extends BroadcastReceiver {
23 private final String TAG = "CollServiceReceiver"; 23 private final String TAG = "CollServiceReceiver";
24 24
25 public CollServiceReceiver() { 25 public CollServiceReceiver() {
26 - 26 + super();
27 } 27 }
28 28
29 public CollServiceReceiver(PowerManager.WakeLock wakeLock) { 29 public CollServiceReceiver(PowerManager.WakeLock wakeLock) {
@@ -72,7 +72,7 @@ public class CollServiceReceiver extends BroadcastReceiver { @@ -72,7 +72,7 @@ public class CollServiceReceiver extends BroadcastReceiver {
72 } 72 }
73 Log.e(TAG, "启动KeepLiveService"); 73 Log.e(TAG, "启动KeepLiveService");
74 } else { 74 } else {
75 - Log.e(TAG, "KeepLiveService已经在运行"); 75 + Log.e(TAG, "collKeepLiveService已经在运行");
76 76
77 } 77 }
78 String action = intent.getAction(); 78 String action = intent.getAction();
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollKeepLiveService.java
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint; @@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
4 import android.app.Notification; 4 import android.app.Notification;
5 import android.app.NotificationChannel; 5 import android.app.NotificationChannel;
6 import android.app.NotificationManager; 6 import android.app.NotificationManager;
  7 +import android.app.PendingIntent;
7 import android.app.Service; 8 import android.app.Service;
8 import android.content.ComponentName; 9 import android.content.ComponentName;
9 import android.content.Context; 10 import android.content.Context;
@@ -19,6 +20,8 @@ import android.util.Log; @@ -19,6 +20,8 @@ import android.util.Log;
19 20
20 import com.cnlive.moudle.collectionTrace.receivers.CollServiceReceiver; 21 import com.cnlive.moudle.collectionTrace.receivers.CollServiceReceiver;
21 import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo; 22 import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
  23 +import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningMapActivity;
  24 +import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity;
22 import com.cnlive.moudle.pedometer.utils.ServiceUtils; 25 import com.cnlive.moudle.pedometer.utils.ServiceUtils;
23 import com.example.moudle_pedometer.R; 26 import com.example.moudle_pedometer.R;
24 27
@@ -36,19 +39,19 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -36,19 +39,19 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
36 public static MediaPlayer mMediaPlayer; 39 public static MediaPlayer mMediaPlayer;
37 //广播 40 //广播
38 private static CollServiceReceiver myReceiver; 41 private static CollServiceReceiver myReceiver;
39 - private String CHANNEL_ONE_ID = "com.cnlive.keep";  
40 - private String CHANNEL_ONE_NAME = "KeepLive"; 42 + private String CHANNEL_ONE_ID = "com.cnlive.collkeep";
  43 + private String CHANNEL_ONE_NAME = "collKeepLive";
41 private NotificationManager mNM; 44 private NotificationManager mNM;
42 private Notification notification = null; 45 private Notification notification = null;
43 //是否在后台运行 46 //是否在后台运行
44 public static boolean isKeepService = true; 47 public static boolean isKeepService = true;
45 public static CollKeepLiveService instance; 48 public static CollKeepLiveService instance;
46 - private int startId;  
47 private final String TAG = "CollKeepLiveService"; 49 private final String TAG = "CollKeepLiveService";
48 private Handler handler; 50 private Handler handler;
49 private Runnable runnable; 51 private Runnable runnable;
50 private boolean isRegisterReceiver = false; 52 private boolean isRegisterReceiver = false;
51 private boolean isStartForegroundService = false; 53 private boolean isStartForegroundService = false;
  54 + private final int NOTIFICATION_ID = 1;
52 55
53 public CollKeepLiveService() { 56 public CollKeepLiveService() {
54 } 57 }
@@ -70,7 +73,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -70,7 +73,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
70 handler.postDelayed(this, 5000); 73 handler.postDelayed(this, 5000);
71 } else { 74 } else {
72 try { 75 try {
73 - if (myReceiver != null&&isRegisterReceiver) { 76 + if (myReceiver != null && isRegisterReceiver) {
74 unregisterReceiver(myReceiver); 77 unregisterReceiver(myReceiver);
75 } 78 }
76 } catch (Exception e) { 79 } catch (Exception e) {
@@ -143,16 +146,15 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -143,16 +146,15 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
143 } 146 }
144 } 147 }
145 } 148 }
146 - this.startId = startId;  
147 //跨进程读取配置文件 149 //跨进程读取配置文件
148 boolean isRun = CollCommonInfo.getIsRunKeepAliveService(getApplicationContext()); 150 boolean isRun = CollCommonInfo.getIsRunKeepAliveService(getApplicationContext());
149 151
150 if (isRun) { 152 if (isRun) {
  153 + showHideForegroundNotification();
  154 + startPlaySong();
151 if (runnable != null) { 155 if (runnable != null) {
152 handler.postDelayed(runnable, 5000); 156 handler.postDelayed(runnable, 5000);
153 } 157 }
154 - showHideForegroundNotification();  
155 - startPlaySong();  
156 } 158 }
157 return START_STICKY; 159 return START_STICKY;
158 } 160 }
@@ -205,21 +207,26 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -205,21 +207,26 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
205 channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PRIVATE); 207 channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PRIVATE);
206 mNM.createNotificationChannel(channel); 208 mNM.createNotificationChannel(channel);
207 } 209 }
  210 + Intent notificationIntent = new Intent(this, CollRunningMapActivity.class);
208 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID) 211 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID)
  212 + .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0))
  213 + .setSmallIcon(R.mipmap.ic_launcher)
  214 +// .setCustomContentView(remoteViews)
209 .setContentTitle(getResources().getString(R.string.app_name)) 215 .setContentTitle(getResources().getString(R.string.app_name))
210 - .setContentText("正在记录您的运动")  
211 - .setWhen(System.currentTimeMillis()) 216 + .setContentText(getResources().getString(R.string.keep_service_tip))
  217 + .setCategory(Notification.CATEGORY_SERVICE)
212 .setSound(null) 218 .setSound(null)
  219 + .setWhen(System.currentTimeMillis())
213 .build(); 220 .build();
214 // 0 隐藏前台服务通知 221 // 0 隐藏前台服务通知
215 - startForeground(100, notification); 222 + startForeground(NOTIFICATION_ID, notification);
216 isStartForegroundService = true; 223 isStartForegroundService = true;
217 -// stopForeground(true);  
218 } 224 }
219 225
220 @Override 226 @Override
221 public void onDestroy() { 227 public void onDestroy() {
222 super.onDestroy(); 228 super.onDestroy();
  229 + Log.e(TAG, "onDestroy: ");
223 try { 230 try {
224 if (myReceiver != null && isRegisterReceiver) { 231 if (myReceiver != null && isRegisterReceiver) {
225 unregisterReceiver(myReceiver); 232 unregisterReceiver(myReceiver);
@@ -268,7 +275,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -268,7 +275,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
268 @Override 275 @Override
269 public void onCompletion(MediaPlayer mediaPlayer) { 276 public void onCompletion(MediaPlayer mediaPlayer) {
270 boolean isRun = CollCommonInfo.getIsRunKeepAliveService(getApplicationContext()); 277 boolean isRun = CollCommonInfo.getIsRunKeepAliveService(getApplicationContext());
271 - 278 + Log.e(TAG, "onCompletion: 是否循环播放" + isRun);
272 if (isRun) { 279 if (isRun) {
273 Log.e(TAG, "重新播放"); 280 Log.e(TAG, "重新播放");
274 mediaPlayer.start(); 281 mediaPlayer.start();
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollStepService.java
@@ -36,6 +36,7 @@ import com.baidu.trace.model.OnTraceListener; @@ -36,6 +36,7 @@ import com.baidu.trace.model.OnTraceListener;
36 import com.baidu.trace.model.PushMessage; 36 import com.baidu.trace.model.PushMessage;
37 import com.baidu.trace.model.StatusCodes; 37 import com.baidu.trace.model.StatusCodes;
38 import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo; 38 import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
  39 +import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningMapActivity;
39 import com.cnlive.moudle.pedometer.model.Constant; 40 import com.cnlive.moudle.pedometer.model.Constant;
40 import com.cnlive.moudle.pedometer.model.MessageEvent; 41 import com.cnlive.moudle.pedometer.model.MessageEvent;
41 import com.cnlive.moudle.pedometer.model.step.StepCount; 42 import com.cnlive.moudle.pedometer.model.step.StepCount;
@@ -116,7 +117,7 @@ public class CollStepService extends Service implements SensorEventListener { @@ -116,7 +117,7 @@ public class CollStepService extends Service implements SensorEventListener {
116 private String userId; 117 private String userId;
117 private Handler handler; 118 private Handler handler;
118 private Runnable speedRunnable; 119 private Runnable speedRunnable;
119 - private final int NOTIFICATION_ID = 100; 120 + private final int NOTIFICATION_ID = 101;
120 // private static int tempStep;//计步器临时保存步数 121 // private static int tempStep;//计步器临时保存步数
121 private static boolean pauseFlag;//是否暂停 122 private static boolean pauseFlag;//是否暂停
122 private static int speedCurrentStep;//用于检测速度步数 123 private static int speedCurrentStep;//用于检测速度步数
@@ -372,6 +373,7 @@ public class CollStepService extends Service implements SensorEventListener { @@ -372,6 +373,7 @@ public class CollStepService extends Service implements SensorEventListener {
372 @SuppressLint("WrongConstant") 373 @SuppressLint("WrongConstant")
373 @Override 374 @Override
374 public int onStartCommand(Intent intent, int flags, int startId) { 375 public int onStartCommand(Intent intent, int flags, int startId) {
  376 +
375 if (!EventBus.getDefault().isRegistered(this)) { 377 if (!EventBus.getDefault().isRegistered(this)) {
376 EventBus.getDefault().register(this); 378 EventBus.getDefault().register(this);
377 } 379 }
@@ -437,13 +439,13 @@ public class CollStepService extends Service implements SensorEventListener { @@ -437,13 +439,13 @@ public class CollStepService extends Service implements SensorEventListener {
437 } 439 }
438 440
439 441
440 - Intent notificationIntent = new Intent(this, PedometerMainActivity.class); 442 + Intent notificationIntent = new Intent(this, CollRunningMapActivity.class);
441 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID) 443 notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID)
442 .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0)) 444 .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0))
443 .setSmallIcon(R.mipmap.ic_launcher) 445 .setSmallIcon(R.mipmap.ic_launcher)
444 // .setCustomContentView(remoteViews) 446 // .setCustomContentView(remoteViews)
445 .setContentTitle(getResources().getString(R.string.app_name)) 447 .setContentTitle(getResources().getString(R.string.app_name))
446 - .setContentText("正在记录您的运动") 448 + .setContentText(getResources().getString(R.string.step_service_tip))
447 .setCategory(Notification.CATEGORY_SERVICE) 449 .setCategory(Notification.CATEGORY_SERVICE)
448 .setSound(null) 450 .setSound(null)
449 .setWhen(System.currentTimeMillis()) 451 .setWhen(System.currentTimeMillis())
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/KeepLiveService.java
@@ -51,7 +51,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -51,7 +51,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
51 private Runnable runnable; 51 private Runnable runnable;
52 private boolean isRegisterReceiver = false; 52 private boolean isRegisterReceiver = false;
53 private boolean isStartForeground = false; 53 private boolean isStartForeground = false;
54 - 54 + private final int NOTIFICATION_ID = 1;
55 public KeepLiveService() { 55 public KeepLiveService() {
56 } 56 }
57 57
@@ -230,13 +230,13 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -230,13 +230,13 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
230 .setSmallIcon(R.mipmap.ic_launcher) 230 .setSmallIcon(R.mipmap.ic_launcher)
231 // .setCustomContentView(remoteViews) 231 // .setCustomContentView(remoteViews)
232 .setContentTitle(getResources().getString(R.string.app_name)) 232 .setContentTitle(getResources().getString(R.string.app_name))
233 - .setContentText("正在记录您的运动") 233 + .setContentText(getResources().getString(R.string.keep_service_tip))
234 .setCategory(Notification.CATEGORY_SERVICE) 234 .setCategory(Notification.CATEGORY_SERVICE)
235 .setSound(null) 235 .setSound(null)
236 .setWhen(System.currentTimeMillis()) 236 .setWhen(System.currentTimeMillis())
237 .build(); 237 .build();
238 // 0 隐藏前台服务通知 238 // 0 隐藏前台服务通知
239 - startForeground(100, notification); 239 + startForeground(NOTIFICATION_ID, notification);
240 isStartForeground=true; 240 isStartForeground=true;
241 } 241 }
242 242
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
@@ -136,7 +136,7 @@ public class StepService extends Service implements SensorEventListener { @@ -136,7 +136,7 @@ public class StepService extends Service implements SensorEventListener {
136 private String userId; 136 private String userId;
137 private Handler handler; 137 private Handler handler;
138 private Runnable speedRunnable; 138 private Runnable speedRunnable;
139 - private final int NOTIFICATION_ID = 100; 139 + private final int NOTIFICATION_ID = 102;
140 // private static int tempStep;//计步器临时保存步数 140 // private static int tempStep;//计步器临时保存步数
141 private static boolean pauseFlag;//是否暂停 141 private static boolean pauseFlag;//是否暂停
142 private static int speedCurrentStep;//用于检测速度步数 142 private static int speedCurrentStep;//用于检测速度步数
@@ -619,7 +619,7 @@ public class StepService extends Service implements SensorEventListener { @@ -619,7 +619,7 @@ public class StepService extends Service implements SensorEventListener {
619 .setSmallIcon(R.mipmap.ic_launcher) 619 .setSmallIcon(R.mipmap.ic_launcher)
620 // .setCustomContentView(remoteViews) 620 // .setCustomContentView(remoteViews)
621 .setContentTitle(getResources().getString(R.string.app_name)) 621 .setContentTitle(getResources().getString(R.string.app_name))
622 - .setContentText("正在记录您的运动") 622 + .setContentText(getResources().getString(R.string.step_service_tip))
623 .setCategory(Notification.CATEGORY_SERVICE) 623 .setCategory(Notification.CATEGORY_SERVICE)
624 .setSound(null) 624 .setSound(null)
625 .setWhen(System.currentTimeMillis()) 625 .setWhen(System.currentTimeMillis())
moudle_pedometer/src/main/res/values/strings.xml
@@ -94,4 +94,6 @@ @@ -94,4 +94,6 @@
94 <string name="layout_coll_take_point_text">(打点)</string> 94 <string name="layout_coll_take_point_text">(打点)</string>
95 <!--默认头像url--> 95 <!--默认头像url-->
96 <string name="default_face_url">http://wjj.ys1.cnliveimg.com/769/img/2018/0416/head_c.png</string> 96 <string name="default_face_url">http://wjj.ys1.cnliveimg.com/769/img/2018/0416/head_c.png</string>
  97 + <string name="step_service_tip">正在记录您的运动</string>
  98 + <string name="keep_service_tip">正在运行,请不要停止,否则无法记录您的轨迹</string>
97 </resources> 99 </resources>