Skip to content

Commit

Permalink
加开关控制是否通过WorkManager来启动安卓12的后台服务
Browse files Browse the repository at this point in the history
  • Loading branch information
lizixian committed Jan 31, 2023
1 parent 9957afb commit 156019a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/main/java/com/lzx/musiclib/TestApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.danikula.videocache.file.Md5FileNameGenerator
import com.lzx.musiclib.viewmodel.MusicViewModel
import com.lzx.starrysky.SongInfo
import com.lzx.starrysky.StarrySkyInstall
import com.lzx.starrysky.StarrySkyInstall.setOpenCache
import com.lzx.starrysky.cache.ICache
import com.lzx.starrysky.intercept.InterceptCallback
import com.lzx.starrysky.intercept.InterceptorThread
Expand Down Expand Up @@ -52,6 +53,7 @@ open class TestApplication : Application() {
pendingIntentMode { NotificationConfig.MODE_BROADCAST }
}
StarrySkyInstall.init(this)
.startForegroundByWorkManager(true)
.setOpenCache(true)
.setAutoManagerFocus(false) //使用多实例的时候要关掉,不然会相互抢焦点
.setCacheDestFileDir("000StarrySkyCache/".toSdcardPath())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ object StarrySkyInstall {
/**
* 是否使用 WorkManager
*/
fun startForegroundByWorkManager(value: Boolean) {
fun startForegroundByWorkManager(value: Boolean) = apply {
isStartForegroundByWorkManager = value
}

Expand Down

0 comments on commit 156019a

Please sign in to comment.