kunfei 3 年之前
父節點
當前提交
73fa4d89e4

+ 7 - 2
app/src/main/java/io/legado/app/constant/AppLog.kt

@@ -3,6 +3,8 @@ package io.legado.app.constant
 import android.util.Log
 import io.legado.app.BuildConfig
 import io.legado.app.help.config.AppConfig
+import io.legado.app.utils.toastOnUi
+import splitties.init.appCtx
 
 object AppLog {
 
@@ -11,8 +13,11 @@ object AppLog {
     val logs get() = mLogs.toList()
 
     @Synchronized
-    fun put(message: String?, throwable: Throwable? = null) {
+    fun put(message: String?, throwable: Throwable? = null, toast: Boolean = false) {
         message ?: return
+        if (toast) {
+            appCtx.toastOnUi(message)
+        }
         if (mLogs.size > 100) {
             mLogs.removeLastOrNull()
         }
@@ -29,7 +34,7 @@ object AppLog {
     }
 
     fun putDebug(message: String?, throwable: Throwable? = null) {
-        if (AppConfig.recordLog || BuildConfig.DEBUG) {
+        if (AppConfig.recordLog) {
             put(message, throwable)
         }
     }

+ 4 - 0
app/src/main/java/io/legado/app/service/BaseReadAloudService.kt

@@ -425,6 +425,10 @@ abstract class BaseReadAloudService : BaseService(),
             builder
         }.onSuccess {
             startForeground(AppConst.notificationIdRead, it.build())
+        }.onError {
+            AppLog.put("创建朗读通知出错,${it.localizedMessage}", it, true)
+            //创建通知出错不结束服务就会崩溃,服务必须绑定通知
+            stopSelf()
         }
     }