Commit 0145597a authored by 周文华's avatar 周文华

【修复】修复局部崩溃

parent 6b41d825
...@@ -33,7 +33,8 @@ object NotificationHoverUtils { ...@@ -33,7 +33,8 @@ object NotificationHoverUtils {
// 创建 Handler // 创建 Handler
if (handler == null) { if (handler == null) {
handlerThread?.let { handlerThread?.let {
handler = Handler(it.getLooper()) val looper=it.getLooper()?:return
handler = Handler(looper)
} }
} }
......
...@@ -121,11 +121,15 @@ class StayJobService : JobService() { ...@@ -121,11 +121,15 @@ class StayJobService : JobService() {
private fun startForeground() { private fun startForeground() {
val notification = createPermanentNotification(applicationContext) val notification = createPermanentNotification(applicationContext)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground( try {
NOTIFICATION_PERMANENT_ID, startForeground(
notification, NOTIFICATION_PERMANENT_ID,
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC notification,
) ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
)
} catch (e: Exception) {
//这里针对高版本的崩溃
}
} else { } else {
startForeground(NOTIFICATION_PERMANENT_ID, notification) startForeground(NOTIFICATION_PERMANENT_ID, notification)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment