From 9934221823d8f395399e21c800a769d4e2e788c1 Mon Sep 17 00:00:00 2001 From: lisonge Date: Wed, 29 Nov 2023 10:08:03 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=97=A0=E9=9A=9C?= =?UTF-8?q?=E7=A2=8D=E5=BC=B9=E7=AA=97=E5=88=9B=E5=BB=BA=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/li/songe/gkd/service/GkdAbService.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/li/songe/gkd/service/GkdAbService.kt b/app/src/main/java/li/songe/gkd/service/GkdAbService.kt index 69e515c..736125d 100644 --- a/app/src/main/java/li/songe/gkd/service/GkdAbService.kt +++ b/app/src/main/java/li/songe/gkd/service/GkdAbService.kt @@ -12,6 +12,7 @@ import android.view.WindowManager import android.view.accessibility.AccessibilityEvent import com.blankj.utilcode.util.LogUtils import com.blankj.utilcode.util.ServiceUtils +import com.blankj.utilcode.util.ToastUtils import io.ktor.client.request.get import io.ktor.client.statement.bodyAsText import kotlinx.coroutines.Dispatchers @@ -302,7 +303,12 @@ class GkdAbService : CompositionAbService({ height = 1 } withContext(Dispatchers.Main) { - wm.addView(aliveView, lp) + try { + wm.addView(aliveView, lp) + } catch (e: Exception) { + LogUtils.d(e) + ToastUtils.showShort("创建无障碍悬浮窗失败!") + } } } else { aliveView = null