Commit 657f2925 by 刘鹏

feat : PlayService ANR问题修复

parent f526aab6
...@@ -5,18 +5,18 @@ ext { ...@@ -5,18 +5,18 @@ ext {
ydlPublishVersion = [ ydlPublishVersion = [
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
"m-confide" : "0.0.49.65", "m-confide" : "0.0.49.69",
"m-consultant" : "0.0.60.16", "m-consultant" : "0.0.60.16",
"m-fm" : "0.0.30.04", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.04", "m-user" : "0.0.62.04",
"m-home" : "0.0.23.17", "m-home" : "0.0.23.18",
"m-im" : "0.0.21.29", "m-im" : "0.0.21.29",
"m-dynamic" : "0.0.7.35", "m-dynamic" : "0.0.7.35",
"m-article" : "0.0.0.10", "m-article" : "0.0.0.10",
"m-muse" : "0.0.28.27", "m-muse" : "0.0.28.28",
"m-tests" : "0.0.24.18", "m-tests" : "0.0.24.18",
"m-course" : "0.0.43.36", "m-course" : "0.0.43.37",
//-------------- 业务模块 API 层 -------------- //-------------- 业务模块 API 层 --------------
"m-audioim-api" : "0.0.6", "m-audioim-api" : "0.0.6",
...@@ -40,7 +40,7 @@ ext { ...@@ -40,7 +40,7 @@ ext {
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.38.61", "ydl-webview" : "0.0.38.61",
"ydl-media" : "0.0.21.42", "ydl-media" : "0.0.21.44",
"ydl-pay" : "0.0.18.19", "ydl-pay" : "0.0.18.19",
"m-audioim" : "0.0.49.29.85", "m-audioim" : "0.0.49.29.85",
"ydl-flutter-base": "0.0.14.38", "ydl-flutter-base": "0.0.14.38",
...@@ -92,18 +92,18 @@ ext { ...@@ -92,18 +92,18 @@ ext {
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
"m-confide" : "0.0.49.65", "m-confide" : "0.0.49.69",
"m-consultant" : "0.0.60.16", "m-consultant" : "0.0.60.16",
"m-fm" : "0.0.30.07", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.04", "m-user" : "0.0.62.04",
"m-home" : "0.0.23.17", "m-home" : "0.0.23.18",
"m-im" : "0.0.21.29", "m-im" : "0.0.21.29",
"m-dynamic" : "0.0.7.35", "m-dynamic" : "0.0.7.35",
"m-article" : "0.0.0.8", "m-article" : "0.0.0.8",
"m-muse" : "0.0.28.27", "m-muse" : "0.0.28.28",
"m-tests" : "0.0.24.18", "m-tests" : "0.0.24.18",
"m-course" : "0.0.43.36", "m-course" : "0.0.43.37",
//-------------- 业务模块 API 层 -------------- //-------------- 业务模块 API 层 --------------
"m-audioim-api" : "0.0.6", "m-audioim-api" : "0.0.6",
"m-confide-api" : "0.0.2.11", "m-confide-api" : "0.0.2.11",
...@@ -125,7 +125,7 @@ ext { ...@@ -125,7 +125,7 @@ ext {
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.38.61", "ydl-webview" : "0.0.38.61",
"ydl-media" : "0.0.21.42", "ydl-media" : "0.0.21.44",
"ydl-pay" : "0.0.18.19", "ydl-pay" : "0.0.18.19",
"m-audioim" : "0.0.49.29.85", "m-audioim" : "0.0.49.29.85",
"ydl-flutter-base": "0.0.14.38", "ydl-flutter-base": "0.0.14.38",
......
...@@ -66,7 +66,16 @@ class PlayService : Service() { ...@@ -66,7 +66,16 @@ class PlayService : Service() {
fun startCommand(context: Context, action: String) { fun startCommand(context: Context, action: String) {
val intent = Intent(context, PlayService::class.java) val intent = Intent(context, PlayService::class.java)
intent.action = action intent.action = action
context.startService(intent)
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intent)
}else{
context.startService(intent)
}
} catch (e: Exception) {
e.printStackTrace()
}
} }
} }
} }
...@@ -47,19 +47,19 @@ class NotifyManager private constructor() { ...@@ -47,19 +47,19 @@ class NotifyManager private constructor() {
if (music == null) { if (music == null) {
return return
} }
playService!!.startForeground(NOTIFICATION_ID, buildNotification(playService!!, music, true)) playService?.startForeground(NOTIFICATION_ID, buildNotification(playService!!, music, true))
} }
fun showPause(music: Music?) { fun showPause(music: Music?) {
if (music == null) { if (music == null) {
return return
} }
playService!!.stopForeground(false) playService?.stopForeground(false)
notificationManager!!.notify(NOTIFICATION_ID, buildNotification(playService!!, music, false)) notificationManager?.notify(NOTIFICATION_ID, buildNotification(playService!!, music, false))
} }
fun cancelAll() { fun cancelAll() {
notificationManager!!.cancelAll() notificationManager?.cancelAll()
} }
@SuppressLint("WrongConstant") @SuppressLint("WrongConstant")
......
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