fix: 前台服务被限制启动导致闪退
This commit is contained in:
parent
366810b78c
commit
e79ead4594
|
|
@ -69,6 +69,7 @@ object TiebaUtil {
|
|||
fun startSign(context: Context) {
|
||||
context.appPreferences.signDay = Calendar.getInstance()[Calendar.DAY_OF_MONTH]
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
try {
|
||||
context.startForegroundService(
|
||||
Intent()
|
||||
.setClassName(
|
||||
|
|
@ -78,6 +79,9 @@ object TiebaUtil {
|
|||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.setAction(OKSignService.ACTION_START_SIGN)
|
||||
)
|
||||
} catch (e: IllegalStateException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} else {
|
||||
context.startService(
|
||||
Intent()
|
||||
|
|
|
|||
Loading…
Reference in New Issue