diff --git a/bytheway/build.properties b/bytheway/build.properties index d208450..f9d39e4 100644 --- a/bytheway/build.properties +++ b/bytheway/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Mon Jul 06 20:21:37 CST 2026 +#Mon Jul 06 20:33:32 CST 2026 stageCount=2 libraryProject= baseVersion=15.20 publishVersion=15.20.1 -buildCount=14 +buildCount=16 baseBetaVersion=15.20.2 diff --git a/bytheway/src/main/java/cc/winboll/studio/bytheway/services/GpsReceiveService.java b/bytheway/src/main/java/cc/winboll/studio/bytheway/services/GpsReceiveService.java index c4e0ba0..3012051 100644 --- a/bytheway/src/main/java/cc/winboll/studio/bytheway/services/GpsReceiveService.java +++ b/bytheway/src/main/java/cc/winboll/studio/bytheway/services/GpsReceiveService.java @@ -27,6 +27,7 @@ public class GpsReceiveService extends Service { private static final String CHANNEL_ID = "gps_receive_service_channel"; private static boolean serviceRunning = false; + private int gpsReceiveCount = 0; private BroadcastReceiver gpsServiceBroadcastReceiver; /** @@ -67,13 +68,14 @@ public class GpsReceiveService extends Service { public void onCreate() { super.onCreate(); serviceRunning = true; + gpsReceiveCount = 0; registerGpsServiceBroadcast(); - startForeground(NOTIFICATION_ID, createNotification()); + startForeground(NOTIFICATION_ID, createNotification(gpsReceiveCount)); LogUtils.i("GpsReceiveService", "GPS定位消息接收服务创建完成"); Toast.makeText(this, "GPS定位消息接收服务已开启", Toast.LENGTH_SHORT).show(); } - private Notification createNotification() { + private Notification createNotification(final int count) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel( CHANNEL_ID, @@ -85,12 +87,20 @@ public class GpsReceiveService extends Service { } return new Notification.Builder(this, CHANNEL_ID) .setContentTitle("ByTheWay") - .setContentText("GPS定位消息接收服务运行中") + .setContentText("已接收GPS数据 " + count + " 次") .setSmallIcon(android.R.drawable.ic_menu_mylocation) .setOngoing(true) .build(); } + /** + * 更新前台服务通知栏显示 + */ + private void updateNotification() { + final NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + manager.notify(NOTIFICATION_ID, createNotification(gpsReceiveCount)); + } + /** * 动态注册GPS定位广播接收器 */ @@ -114,7 +124,9 @@ public class GpsReceiveService extends Service { private void parseAndSaveGpsData(final Intent intent) { final GpsBean bean = GpsUtil.parseFromIntent(intent); GpsUtil.insertGps(getApplicationContext(), bean); - LogUtils.d("GpsReceiveService", "收到GPS广播,已保存定位数据"); + gpsReceiveCount++; + updateNotification(); + LogUtils.d("GpsReceiveService", "收到GPS广播,已保存定位数据,累计接收 " + gpsReceiveCount + " 次"); } @Override