diff --git a/timestamp/build.properties b/timestamp/build.properties index 62e827f..cf9ff9e 100644 --- a/timestamp/build.properties +++ b/timestamp/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Mon May 05 03:50:53 GMT 2025 +#Mon May 05 04:37:03 GMT 2025 stageCount=0 libraryProject= baseVersion=15.0 publishVersion=15.0.0 -buildCount=24 +buildCount=26 baseBetaVersion=15.0.1 diff --git a/timestamp/src/main/AndroidManifest.xml b/timestamp/src/main/AndroidManifest.xml index 86517cb..bff1a04 100644 --- a/timestamp/src/main/AndroidManifest.xml +++ b/timestamp/src/main/AndroidManifest.xml @@ -39,12 +39,6 @@ - - - - - - diff --git a/timestamp/src/main/java/cc/winboll/studio/timestamp/MainService.java b/timestamp/src/main/java/cc/winboll/studio/timestamp/MainService.java index 4a00e01..6f35492 100644 --- a/timestamp/src/main/java/cc/winboll/studio/timestamp/MainService.java +++ b/timestamp/src/main/java/cc/winboll/studio/timestamp/MainService.java @@ -31,6 +31,7 @@ import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Timer; import java.util.TimerTask; +import android.content.IntentFilter; public class MainService extends Service { @@ -38,6 +39,7 @@ public class MainService extends Service { public static final int MSG_UPDATE_TIMESTAMP = 0; + ButtonClickReceiver mButtonClickReceiver; Intent intentMainService; Intent mButtonBroadcastIntent; PendingIntent mButtonPendingIntent; @@ -73,6 +75,17 @@ public class MainService extends Service { mButtonBroadcastIntent, // Intent PendingIntent.FLAG_UPDATE_CURRENT // 标志位,用于更新已存在的 PendingIntent ); + // 为按钮设置点击事件 + mRemoteViews.setOnClickPendingIntent(R.id.btn_copytimestamp, mButtonPendingIntent); + + // 创建广播接收器实例 + mButtonClickReceiver = new ButtonClickReceiver(); + + // 创建 IntentFilter 并设置要接收的广播动作 + IntentFilter filter = new IntentFilter(ButtonClickReceiver.BUTTON_COPYTIMESTAMP_ACTION); + + // 注册广播接收器 + registerReceiver(mButtonClickReceiver, filter); LogUtils.d(TAG, "onCreate()"); _mIsServiceAlive = false; @@ -189,8 +202,6 @@ public class MainService extends Service { String formattedDateTime = ldt.format(formatter); //System.out.println(formattedDateTime); mRemoteViews.setTextViewText(R.id.tv_timestamp, formattedDateTime); - // 为按钮设置点击事件 - mRemoteViews.setOnClickPendingIntent(R.id.btn_copytimestamp, mButtonPendingIntent); notification = mNotificationHelper.showCustomForegroundNotification(intentMainService, mRemoteViews, mRemoteViews); //startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, notification); }