From 8bddca499630d6282e6b6b13fa3de4a6a4a6f2df Mon Sep 17 00:00:00 2001 From: fengge <844143714@qq.com> Date: Mon, 1 Jun 2026 18:08:10 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D:=20=E4=BF=AE=E5=A4=8DPTT?= =?UTF-8?q?=E5=BF=83=E8=B7=B3=E7=BA=BF=E7=A8=8B=E6=B1=A0=E6=B0=B8=E4=B9=85?= =?UTF-8?q?=E6=B3=84=E6=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/kingway/ptt/CallBackResolution.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/kingway/ptt/CallBackResolution.java b/app/src/main/java/com/example/kingway/ptt/CallBackResolution.java index e2d0187..7fef131 100644 --- a/app/src/main/java/com/example/kingway/ptt/CallBackResolution.java +++ b/app/src/main/java/com/example/kingway/ptt/CallBackResolution.java @@ -28,6 +28,7 @@ public class CallBackResolution { private static boolean loginState = false; private static String pttLoginStatus = "00"; // 00-未登录 01-登录中 02-已登录 private static String pttLoginId = ""; + private static ScheduledExecutorService keepAliveExecutor = null; public static String getPttLoginStatus() { return pttLoginStatus; @@ -543,13 +544,16 @@ public class CallBackResolution { if (tempTxt.contains("已登录")) { String showName = tempTxt.substring(3, tempTxt.length()); CallBackUtil.callBackLogin(true, showName); - ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); + if (keepAliveExecutor != null && !keepAliveExecutor.isShutdown()) { + keepAliveExecutor.shutdownNow(); + } + keepAliveExecutor = Executors.newSingleThreadScheduledExecutor(); Runnable task = () -> { Timber.tag(TAG).d( "callBackLogin send tcp and udp"); SendAtUtil.sendUDP(); SendAtUtil.sendTCP(); }; - executor.scheduleAtFixedRate(task, 0, 40, TimeUnit.SECONDS); + keepAliveExecutor.scheduleAtFixedRate(task, 0, 40, TimeUnit.SECONDS); } else if (tempTxt.contains("账号已更新")) { Timber.tag(TAG).w("TTS reports account updated: '%s'", tempTxt); } else if (tempTxt.contains("账号或密码错误")) {