Commit c7aa6d82adba44c030dad9ca974bfd64fe87755e

Authored by 杨帅
1 parent 8ce409e8

1.对接运动赛事详情页接口

2.新增接口签名验证
moudle_pedometer/src/main/AndroidManifest.xml
@@ -61,10 +61,6 @@ @@ -61,10 +61,6 @@
61 <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity" /> 61 <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity" />
62 62
63 <service 63 <service
64 - android:name="com.baidu.location.f"  
65 - android:enabled="true"  
66 - android:process=":remote" />  
67 - <service  
68 android:name="com.cnlive.moudle.pedometer.service.StepService" 64 android:name="com.cnlive.moudle.pedometer.service.StepService"
69 android:enabled="true" 65 android:enabled="true"
70 android:exported="true" 66 android:exported="true"
@@ -98,6 +94,25 @@ @@ -98,6 +94,25 @@
98 </intent-filter> 94 </intent-filter>
99 </service> 95 </service>
100 96
  97 + <service
  98 + android:name="com.cnlive.moudle.pedometer.service.KeepLiveService"
  99 + android:enabled="true"
  100 + android:exported="true"
  101 + android:priority="1000"
  102 + android:process=":re" />
  103 +
  104 + <receiver
  105 + android:name="com.cnlive.moudle.pedometer.receivers.ServiceReceiver"
  106 + android:enabled="true"
  107 + android:exported="true">
  108 + <intent-filter android:priority="1000">
  109 + <action android:name="com.cnlive.strike.receiver.ServiceReceiver" />
  110 + <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
  111 + <action android:name="android.net.wifi.STATE_CHANGE" />
  112 + <action android:name="com.example.myservice.MyReceiver" />
  113 + </intent-filter>
  114 + </receiver>
  115 +
101 <activity 116 <activity
102 android:name="com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity" 117 android:name="com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity"
103 android:launchMode="singleTask" 118 android:launchMode="singleTask"
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunRaceDetailFragmentView.java
@@ -196,11 +196,12 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen @@ -196,11 +196,12 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
196 //设置活动地点 196 //设置活动地点
197 if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) { 197 if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) {
198 fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress()); 198 fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress());
  199 + //设置活动距离
  200 + if (!TextUtils.isEmpty(runRaceDetailInfo.getMileage())) {
  201 + fragment.binding.includeStreet.tvAddress.append("\t\t" + runRaceDetailInfo.getMileage());
  202 + }
199 } 203 }
200 - //设置活动距离  
201 - if (!TextUtils.isEmpty(runRaceDetailInfo.getMileage())) {  
202 - fragment.binding.includeStreet.tvMileage.setText(runRaceDetailInfo.getMileage());  
203 - } 204 +
204 //设置起点 205 //设置起点
205 if (!TextUtils.isEmpty(runRaceDetailInfo.getStartLocation())) { 206 if (!TextUtils.isEmpty(runRaceDetailInfo.getStartLocation())) {
206 fragment.binding.includeStreet.tvStartAddr.setText(runRaceDetailInfo.getStartLocation()); 207 fragment.binding.includeStreet.tvStartAddr.setText(runRaceDetailInfo.getStartLocation());
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
@@ -70,6 +70,26 @@ public class CommonInfo { @@ -70,6 +70,26 @@ public class CommonInfo {
70 } 70 }
71 71
72 /** 72 /**
  73 + * 设置是否运行保活服务
  74 + *
  75 + * @param context
  76 + * @param isAllow
  77 + */
  78 + public static void setIsRunKeepAliveService(Context context, boolean isAllow) {
  79 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("KeepAliveService", isAllow);
  80 +
  81 + }
  82 +
  83 + /**
  84 + * 获取是否运行保活服务
  85 + *
  86 + * @param context
  87 + */
  88 + public static boolean getIsRunKeepAliveService(Context context) {
  89 + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("KeepAliveService", false);
  90 + }
  91 +
  92 + /**
73 * 获取是否运行计步服务 93 * 获取是否运行计步服务
74 * 94 *
75 * @param context 95 * @param context
@@ -97,6 +117,25 @@ public class CommonInfo { @@ -97,6 +117,25 @@ public class CommonInfo {
97 return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("streetId", ""); 117 return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("streetId", "");
98 } 118 }
99 119
  120 + /**
  121 + * 设置是否运行鹰眼服务
  122 + *
  123 + * @param context
  124 + * @param isRun
  125 + */
  126 + public static void setTsRunBaiduTraceService(Context context, boolean isRun) {
  127 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("RunBaiduTraceService", isRun);
  128 + }
  129 +
  130 + /**
  131 + * 获取是否运行鹰眼服务
  132 + *
  133 + * @param context
  134 + */
  135 + public static boolean getIsRunBaiduTraceService(Context context) {
  136 + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("RunBaiduTraceService", false);
  137 + }
  138 +
100 /*重置 139 /*重置
101 * @param context 140 * @param context
102 */ 141 */
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
@@ -205,11 +205,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -205,11 +205,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
205 //设置活动地点 205 //设置活动地点
206 if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) { 206 if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) {
207 fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress()); 207 fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress());
  208 + //设置活动距离
  209 + if (!TextUtils.isEmpty(runRaceDetailInfo.getMileage())) {
  210 + fragment.binding.includeStreet.tvAddress.append("\t\t"+runRaceDetailInfo.getMileage());
  211 + }
208 } 212 }
209 - //设置活动距离  
210 - if (!TextUtils.isEmpty(runRaceDetailInfo.getMileage())) {  
211 - fragment.binding.includeStreet.tvMileage.setText(runRaceDetailInfo.getMileage());  
212 - } 213 +
213 //设置起点 214 //设置起点
214 if (!TextUtils.isEmpty(runRaceDetailInfo.getStartLocation())) { 215 if (!TextUtils.isEmpty(runRaceDetailInfo.getStartLocation())) {
215 fragment.binding.includeStreet.tvStartAddr.setText(runRaceDetailInfo.getStartLocation()); 216 fragment.binding.includeStreet.tvStartAddr.setText(runRaceDetailInfo.getStartLocation());
@@ -255,6 +256,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -255,6 +256,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
255 if (!TextUtils.isEmpty(runRaceDetailInfo.getUserMileage())) { 256 if (!TextUtils.isEmpty(runRaceDetailInfo.getUserMileage())) {
256 //显示 257 //显示
257 fragment.binding.includePersonScore.llPersonScoreRoot.setVisibility(View.VISIBLE); 258 fragment.binding.includePersonScore.llPersonScoreRoot.setVisibility(View.VISIBLE);
  259 + //设置完成人数
  260 + if (!TextUtils.isEmpty(runRaceDetailInfo.getFinishNum())){
  261 + fragment.binding.includeRank.tvFinishPerson.setText(runRaceDetailInfo.getFinishNum());
  262 + }
258 //设置个人行走距离 263 //设置个人行走距离
259 if (!TextUtils.isEmpty(runRaceDetailInfo.getUserMileage())) { 264 if (!TextUtils.isEmpty(runRaceDetailInfo.getUserMileage())) {
260 fragment.binding.includePersonScore.tvUserDistance.setText(runRaceDetailInfo.getUserMileage()); 265 fragment.binding.includePersonScore.tvUserDistance.setText(runRaceDetailInfo.getUserMileage());
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/receivers/ServiceReceiver.java
@@ -8,6 +8,9 @@ import android.os.Build; @@ -8,6 +8,9 @@ import android.os.Build;
8 import android.os.PowerManager; 8 import android.os.PowerManager;
9 import android.util.Log; 9 import android.util.Log;
10 10
  11 +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
  12 +import com.cnlive.moudle.pedometer.service.KeepLiveService;
  13 +import com.cnlive.moudle.pedometer.service.StepService;
11 import com.cnlive.moudle.pedometer.utils.MySpHelper; 14 import com.cnlive.moudle.pedometer.utils.MySpHelper;
12 import com.cnlive.moudle.pedometer.utils.ServiceUtils; 15 import com.cnlive.moudle.pedometer.utils.ServiceUtils;
13 16
@@ -34,15 +37,33 @@ public class ServiceReceiver extends BroadcastReceiver { @@ -34,15 +37,33 @@ public class ServiceReceiver extends BroadcastReceiver {
34 public void onReceive(Context context, Intent intent) { 37 public void onReceive(Context context, Intent intent) {
35 Log.e(TAG, "接收到广播:" + intent.getAction()); 38 Log.e(TAG, "接收到广播:" + intent.getAction());
36 //todo 这里判断要保活的服务 39 //todo 这里判断要保活的服务
37 -// UserService.getUid(context)  
38 - boolean isRun = MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("keepService", false);  
39 - Log.e("isRun", "" + isRun);  
40 - if (isRun) { 40 + boolean isRunStepService = CommonInfo.getIsRunStepService(context);
  41 + if (isRunStepService) {
  42 + if (!ServiceUtils.isServiceRunning(context, "com.cnlive.moudle.pedometer.service.StepService")) {
  43 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  44 + context.startForegroundService(new Intent(context, StepService.class));
  45 + } else {
  46 + context.startService(new Intent(context, StepService.class));
  47 + }
  48 + }
  49 + //判断百度鹰眼是否运行
  50 + boolean isRunBaiduTrace = CommonInfo.getIsRunBaiduTraceService(context);
  51 + if (isRunBaiduTrace) {
  52 + if (!ServiceUtils.isServiceRunning(context, "com.baidu.trace.LBSTraceService")) {
  53 + if (StepService.mClient != null && StepService.mTrace != null && StepService.traceListener != null) {
  54 + StepService.mClient.startTrace(StepService.mTrace, StepService.traceListener);
  55 + }
  56 + }
  57 + }
  58 + }
  59 + //todo 保活
  60 + boolean isRunKeepAliveService = CommonInfo.getIsRunKeepAliveService(context);
  61 + if (isRunKeepAliveService) {
41 if (!ServiceUtils.isServiceRunning(context, "com.cnlive.moudle.pedometer.service.KeepLiveService")) { 62 if (!ServiceUtils.isServiceRunning(context, "com.cnlive.moudle.pedometer.service.KeepLiveService")) {
42 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { 63 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
43 -// context.startForegroundService(new Intent(context, KeepLiveService.class)); 64 + context.startForegroundService(new Intent(context, KeepLiveService.class));
44 } else { 65 } else {
45 -// context.startService(new Intent(context, KeepLiveService.class)); 66 + context.startService(new Intent(context, KeepLiveService.class));
46 } 67 }
47 Log.e(TAG, "启动KeepLiveService"); 68 Log.e(TAG, "启动KeepLiveService");
48 } 69 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/KeepLiveService.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.service;
  2 +
  3 +import android.annotation.SuppressLint;
  4 +import android.app.Notification;
  5 +import android.app.NotificationChannel;
  6 +import android.app.NotificationManager;
  7 +import android.app.Service;
  8 +import android.content.ComponentName;
  9 +import android.content.Context;
  10 +import android.content.Intent;
  11 +import android.content.IntentFilter;
  12 +import android.media.MediaPlayer;
  13 +import android.os.Build;
  14 +import android.os.Handler;
  15 +import android.os.IBinder;
  16 +import android.os.PowerManager;
  17 +import android.support.v4.app.NotificationCompat;
  18 +import android.util.Log;
  19 +
  20 +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
  21 +import com.cnlive.moudle.pedometer.receivers.ServiceReceiver;
  22 +import com.cnlive.moudle.pedometer.utils.ServiceUtils;
  23 +import com.example.moudle_pedometer.R;
  24 +
  25 +
  26 +/**
  27 + * @author ShinnyYang
  28 + * 维持后台运行的服务
  29 + */
  30 +public class KeepLiveService extends Service implements MediaPlayer.OnCompletionListener {
  31 + //唤醒锁
  32 + private PowerManager.WakeLock wakeLock = null;
  33 + //电源管理器
  34 + private PowerManager powerManager = null;
  35 + //音频播放器
  36 + public static MediaPlayer mMediaPlayer;
  37 + //广播
  38 + private static ServiceReceiver myReceiver;
  39 + private String CHANNEL_ONE_ID = "com.cnlive.keep";
  40 + private String CHANNEL_ONE_NAME = "KeepLive";
  41 + private NotificationManager mNM;
  42 + private Notification notification = null;
  43 + //是否在后台运行
  44 + public static boolean isKeepService = true;
  45 + public static KeepLiveService instance;
  46 + private int startId;
  47 + private final String TAG = "KeepLiveService";
  48 + private Handler handler;
  49 + private Runnable runnable;
  50 +
  51 + public KeepLiveService() {
  52 + }
  53 +
  54 + public static KeepLiveService getInstance() {
  55 + if (instance == null) {
  56 + instance = new KeepLiveService();
  57 + return instance;
  58 + } else {
  59 + return instance;
  60 + }
  61 + }
  62 +
  63 + @Override
  64 + public void onCreate() {
  65 + super.onCreate();
  66 + instance = this;
  67 +// if (!ServiceUtils.isServiceRunning(getApplicationContext(), "com.cnlive.moudle.pedometer.service.StepService")) {
  68 +// startService(new Intent(getApplicationContext(), StepService.class));
  69 +// }
  70 + init();
  71 + initBroadCastReceiver();
  72 + handler = new Handler();
  73 + runnable = new Runnable() {
  74 + @Override
  75 + public void run() {
  76 + //跨进程读取配置文件
  77 + boolean isRun = CommonInfo.getIsRunKeepAliveService(getApplicationContext());
  78 + if (isRun) {
  79 + handler.postDelayed(this, 5000);
  80 + } else {
  81 +// try {
  82 +// if (myReceiver != null) {
  83 +// unregisterReceiver(myReceiver);
  84 +// }
  85 +// } catch (Exception e) {
  86 +// Log.e(TAG, "run: ");
  87 +// }
  88 + stopPlaySong();
  89 + stopForeground(true);
  90 + }
  91 +
  92 + }
  93 + };
  94 +
  95 + }
  96 +
  97 + @Override
  98 + public void onTaskRemoved(Intent rootIntent) {
  99 + super.onTaskRemoved(rootIntent);
  100 + Log.e("onTaskRemoved", "onTaskRemoved");
  101 + }
  102 +
  103 + /**
  104 + * 初始化广播
  105 + */
  106 + private void initBroadCastReceiver() {
  107 + if (wakeLock != null) {
  108 + myReceiver = new ServiceReceiver(wakeLock);
  109 + } else {
  110 + myReceiver = new ServiceReceiver();
  111 + }
  112 + IntentFilter intentFilter = new IntentFilter();
  113 + intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
  114 + intentFilter.addAction(Intent.ACTION_SCREEN_ON);
  115 +// intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
  116 +// intentFilter.addAction(Intent.ACTION_TIME_CHANGED);
  117 +// intentFilter.addAction(Intent.ACTION_POWER_CONNECTED);
  118 +// intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
  119 + intentFilter.addAction("com.cnlive.strike.receiver.ServiceReceiver");
  120 + intentFilter.addAction("close.KeepService");
  121 + registerReceiver(myReceiver, intentFilter);
  122 + }
  123 +
  124 + /**
  125 + * 初始化相关参数
  126 + */
  127 + @SuppressLint("InvalidWakeLockTag")
  128 + private void init() {
  129 + if (null == powerManager) {
  130 + powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  131 + }
  132 + if (null == wakeLock) {
  133 + wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "track upload");
  134 + }
  135 + if (null == mNM) {
  136 + mNM = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  137 + }
  138 +
  139 + }
  140 +
  141 + @SuppressLint("WrongConstant")
  142 + @Override
  143 + public int onStartCommand(Intent intent, int flags, int startId) {
  144 + //判断是否运行计步服务
  145 + boolean isRunStepService = CommonInfo.getIsRunStepService(getApplicationContext());
  146 + if (isRunStepService) {
  147 + if (!ServiceUtils.isServiceRunning(getApplicationContext(), "com.cnlive.moudle.pedometer.service.StepService")) {
  148 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  149 + startForegroundService(new Intent(getApplicationContext(), StepService.class));
  150 + } else {
  151 + startService(new Intent(getApplicationContext(), StepService.class));
  152 + }
  153 + }
  154 + }
  155 + this.startId = startId;
  156 + //跨进程读取配置文件
  157 + boolean isRun = CommonInfo.getIsRunKeepAliveService(getApplicationContext());
  158 + Log.e("isRun onStartCommand", "" + isRun);
  159 +
  160 + if (isRun) {
  161 + if (runnable != null) {
  162 + handler.postDelayed(runnable, 5000);
  163 + }
  164 + showHideForegroundNotification();
  165 +// startService(new Intent(getApplicationContext(), HideKeepTipService.class));
  166 + Log.e(TAG, "启动HideKeepTipService");
  167 + startPlaySong();
  168 + }
  169 + return START_STICKY;
  170 + }
  171 +
  172 + //开始、暂停播放
  173 + public void startPlaySong() {
  174 + if (mMediaPlayer == null) {
  175 + mMediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.no_kill);
  176 + }
  177 + mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
  178 + mMediaPlayer.setOnCompletionListener(this);
  179 +// mMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
  180 +// @Override
  181 +// public boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
  182 +// mMediaPlayer.reset();
  183 +// mMediaPlayer.release();
  184 +// mMediaPlayer = null;
  185 +// startPlaySong();
  186 +// return false;
  187 +// }
  188 +// });
  189 + if (!mMediaPlayer.isPlaying()) {
  190 + mMediaPlayer.start();
  191 + Log.e(TAG, "开始播放");
  192 + }
  193 +
  194 + }
  195 +
  196 + //停止播放销毁对象
  197 + public void stopPlaySong() {
  198 +
  199 + if (mMediaPlayer != null) {
  200 + mMediaPlayer.stop();
  201 + mMediaPlayer.release();
  202 + mMediaPlayer = null;
  203 + Log.e("停止播放", "停止");
  204 + }
  205 + }
  206 +
  207 +
  208 + private void showHideForegroundNotification() {
  209 + NotificationChannel channel = null;
  210 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  211 + channel = new NotificationChannel(CHANNEL_ONE_ID, CHANNEL_ONE_NAME,
  212 + NotificationManager.IMPORTANCE_HIGH);
  213 + channel.enableLights(false);
  214 + channel.enableVibration(false);
  215 + channel.setVibrationPattern(new long[]{0});
  216 + channel.setSound(null, null);
  217 + channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PRIVATE);
  218 + mNM.createNotificationChannel(channel);
  219 + }
  220 + notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID)
  221 + .setWhen(System.currentTimeMillis())
  222 + .setSound(null)
  223 + .build();
  224 + // 0 隐藏前台服务通知
  225 + startForeground(100, notification);
  226 +// stopForeground(true);
  227 + }
  228 +
  229 + @Override
  230 + public void onDestroy() {
  231 + super.onDestroy();
  232 + Log.e("onDestroy", "onDestroy:" + notification);
  233 + if (myReceiver != null) {
  234 + unregisterReceiver(myReceiver);
  235 + }
  236 + try {
  237 +// stopForeground(true);
  238 + } catch (Exception e) {
  239 + }
  240 + stopPlaySong();
  241 + // 重启自己
  242 + if (isKeepService) {
  243 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  244 + startForegroundService(new Intent(getApplicationContext(), KeepLiveService.class));
  245 + } else {
  246 + startService(new Intent(getApplicationContext(), KeepLiveService.class));
  247 + }
  248 + //发送重启广播
  249 + sendRestartBroadCast();
  250 + }
  251 +
  252 +
  253 + }
  254 +
  255 +
  256 + /**
  257 + * 发送重启广播
  258 + */
  259 + private void sendRestartBroadCast() {
  260 + Intent intent = new Intent(" com.cnlive.moudle.pedometer.receivers.MyReceiver");
  261 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  262 + intent.setComponent(new ComponentName(getPackageName(), " com.cnlive.moudle.pedometer.receivers.MyReceiver"));//高版本Android发送广播需要加这句
  263 + }
  264 + sendBroadcast(intent);
  265 + }
  266 +
  267 + @Override
  268 + public IBinder onBind(Intent intent) {
  269 + // TODO: Return the communication channel to the service.
  270 + throw new UnsupportedOperationException("Not yet implemented");
  271 + }
  272 +
  273 +
  274 + /**
  275 + * 歌曲播放完成
  276 + *
  277 + * @param mediaPlayer
  278 + */
  279 + @Override
  280 + public void onCompletion(MediaPlayer mediaPlayer) {
  281 + boolean isRun = CommonInfo.getIsRunKeepAliveService(getApplicationContext());
  282 +
  283 + if (isRun) {
  284 + Log.e(TAG, "重新播放");
  285 + mediaPlayer.start();
  286 + Intent intent = new Intent("com.cnlive.strike.receiver.ServiceReceiver");
  287 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  288 + intent.setComponent(new ComponentName(getPackageName(), "com.cnlive.strike.receiver.ServiceReceiver"));//高版本Android发送广播需要加这句
  289 + }
  290 + sendBroadcast(intent);
  291 + } else {
  292 + Log.e(TAG, "停止重新播放");
  293 + stopPlaySong();
  294 + }
  295 +
  296 +
  297 + }
  298 +}
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
@@ -232,7 +232,6 @@ public class StepService extends Service implements SensorEventListener { @@ -232,7 +232,6 @@ public class StepService extends Service implements SensorEventListener {
232 if (mClient != null) { 232 if (mClient != null) {
233 mClient.startGather(traceListener); 233 mClient.startGather(traceListener);
234 Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show(); 234 Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show();
235 -  
236 } 235 }
237 } 236 }
238 } 237 }
@@ -273,6 +272,8 @@ public class StepService extends Service implements SensorEventListener { @@ -273,6 +272,8 @@ public class StepService extends Service implements SensorEventListener {
273 public void onStartGatherCallback(int errorNo, String message) { 272 public void onStartGatherCallback(int errorNo, String message) {
274 if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STARTED == errorNo) { 273 if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STARTED == errorNo) {
275 Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show(); 274 Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show();
  275 + CommonInfo.setTsRunBaiduTraceService(getApplicationContext(), true);
  276 +
276 } 277 }
277 } 278 }
278 279
@@ -292,6 +293,7 @@ public class StepService extends Service implements SensorEventListener { @@ -292,6 +293,7 @@ public class StepService extends Service implements SensorEventListener {
292 Toast.makeText(getApplicationContext(), "停止采集", Toast.LENGTH_LONG).show(); 293 Toast.makeText(getApplicationContext(), "停止采集", Toast.LENGTH_LONG).show();
293 if (mClient != null) { 294 if (mClient != null) {
294 mClient.stopTrace(mTrace, traceListener); 295 mClient.stopTrace(mTrace, traceListener);
  296 + CommonInfo.setTsRunBaiduTraceService(getApplicationContext(), false);
295 } 297 }
296 } 298 }
297 } 299 }
@@ -356,7 +358,7 @@ public class StepService extends Service implements SensorEventListener { @@ -356,7 +358,7 @@ public class StepService extends Service implements SensorEventListener {
356 @SuppressLint("WrongConstant") 358 @SuppressLint("WrongConstant")
357 @Override 359 @Override
358 public int onStartCommand(Intent intent, int flags, int startId) { 360 public int onStartCommand(Intent intent, int flags, int startId) {
359 - userId =CommonInfo.getUserId(getApplicationContext()); 361 + userId = CommonInfo.getUserId(getApplicationContext());
360 if (userId != null && !TextUtils.isEmpty(userId)) { 362 if (userId != null && !TextUtils.isEmpty(userId)) {
361 if (!EventBus.getDefault().isRegistered(this)) { 363 if (!EventBus.getDefault().isRegistered(this)) {
362 EventBus.getDefault().register(this); 364 EventBus.getDefault().register(this);
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunRaceDetailFragment.java
@@ -7,12 +7,14 @@ import android.support.annotation.NonNull; @@ -7,12 +7,14 @@ import android.support.annotation.NonNull;
7 import android.support.annotation.Nullable; 7 import android.support.annotation.Nullable;
8 import android.support.design.widget.BottomSheetBehavior; 8 import android.support.design.widget.BottomSheetBehavior;
9 import android.support.design.widget.BottomSheetDialog; 9 import android.support.design.widget.BottomSheetDialog;
  10 +import android.text.TextUtils;
10 import android.util.Log; 11 import android.util.Log;
11 import android.view.View; 12 import android.view.View;
12 import android.widget.FrameLayout; 13 import android.widget.FrameLayout;
13 import android.widget.LinearLayout; 14 import android.widget.LinearLayout;
14 15
15 import com.cnlive.libs.base.ui.QMUIFragment; 16 import com.cnlive.libs.base.ui.QMUIFragment;
  17 +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
16 import com.cnlive.moudle.pedometer.frame.presenter.RunRaceDetailFragmentPresenter; 18 import com.cnlive.moudle.pedometer.frame.presenter.RunRaceDetailFragmentPresenter;
17 import com.cnlive.moudle.pedometer.frame.view.RunRaceDetailFragmentView; 19 import com.cnlive.moudle.pedometer.frame.view.RunRaceDetailFragmentView;
18 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; 20 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
@@ -64,7 +66,8 @@ public class RunRaceDetailFragment extends QMUIFragment&lt;RunRaceDetailFragmentVie @@ -64,7 +66,8 @@ public class RunRaceDetailFragment extends QMUIFragment&lt;RunRaceDetailFragmentVie
64 getMvpView().initMap();; 66 getMvpView().initMap();;
65 } 67 }
66 if (getPresenter()!=null){ 68 if (getPresenter()!=null){
67 - getPresenter().getRunRaceDetailInfo(getActivity(),"116","10513196"); 69 + if (!TextUtils.isEmpty(CommonInfo.getStreetId(getActivity())))
  70 + getPresenter().getRunRaceDetailInfo(getActivity(),CommonInfo.getStreetId(getActivity()),"10513196");
68 } 71 }
69 72
70 } 73 }
moudle_pedometer/src/main/res/layout/layout_run_detail_street.xml
@@ -76,14 +76,6 @@ @@ -76,14 +76,6 @@
76 android:textColor="@color/text_black" 76 android:textColor="@color/text_black"
77 android:textSize="15sp" /> 77 android:textSize="15sp" />
78 78
79 - <TextView  
80 - android:id="@+id/tv_mileage"  
81 - android:layout_width="wrap_content"  
82 - android:layout_height="wrap_content"  
83 - android:layout_marginLeft="25dp"  
84 - android:text="-"  
85 - android:textColor="@color/text_black"  
86 - android:textSize="15sp" />  
87 </LinearLayout> 79 </LinearLayout>
88 </LinearLayout> 80 </LinearLayout>
89 <!--按钮--> 81 <!--按钮-->