From e79ead45944a38ebbe4ef88a229d64ff5772dd0d Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Thu, 16 Jun 2022 12:35:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=89=8D=E5=8F=B0=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E8=A2=AB=E9=99=90=E5=88=B6=E5=90=AF=E5=8A=A8=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E9=97=AA=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tieba/post/utils/TiebaUtil.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/utils/TiebaUtil.kt b/app/src/main/java/com/huanchengfly/tieba/post/utils/TiebaUtil.kt index 542f2c26..0443402e 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/utils/TiebaUtil.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/utils/TiebaUtil.kt @@ -69,15 +69,19 @@ object TiebaUtil { fun startSign(context: Context) { context.appPreferences.signDay = Calendar.getInstance()[Calendar.DAY_OF_MONTH] if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - context.startForegroundService( - Intent() - .setClassName( - context.packageName, - "${context.packageName}.services.OKSignService" - ) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - .setAction(OKSignService.ACTION_START_SIGN) - ) + try { + context.startForegroundService( + Intent() + .setClassName( + context.packageName, + "${context.packageName}.services.OKSignService" + ) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + .setAction(OKSignService.ACTION_START_SIGN) + ) + } catch (e: IllegalStateException) { + e.printStackTrace() + } } else { context.startService( Intent()