feat(gpsrelaysentinel): 前台服务通知添加GPS数据计数值

- 添加mGpsCount计数器统计GPS数据接收次数
- 每次onLocationChanged时计数器自增
- 通知栏实时显示GPS数据计数值(Count: x)
- 计数包含在通知内容中:经纬度 | Count: x
This commit is contained in:
2026-05-07 02:56:15 +08:00
parent b3df8c7770
commit b065a20c4d

View File

@@ -28,6 +28,7 @@ public class MainService extends Service {
private static final int NOTIFICATION_ID = 1;
private static final String PREF_NAME = "gps_relay_service_prefs";
private static final String KEY_SERVICE_ENABLED = "service_enabled";
private int mGpsCount = 0;
@Override
public void onCreate() {
@@ -67,6 +68,7 @@ public class MainService extends Service {
mLocationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
mGpsCount++;
String gpsInfo = "Lat: " + location.getLatitude() + ", Lng: " + location.getLongitude();
LogUtils.d(TAG, "Location changed: " + gpsInfo);
updateNotification(gpsInfo);
@@ -129,7 +131,7 @@ public class MainService extends Service {
private void updateNotification(String gpsInfo) {
if (mNotificationBuilder != null) {
mNotificationBuilder.setContentText(gpsInfo);
mNotificationBuilder.setContentText(gpsInfo + " | Count: " + mGpsCount);
mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());
}
}