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