|
|
@@ -1,13 +1,13 @@
|
|
|
package io.legado.app.service
|
|
|
|
|
|
import android.app.Dialog
|
|
|
+import android.app.ForegroundServiceStartNotAllowedException
|
|
|
import android.content.Intent
|
|
|
import android.os.Build
|
|
|
import android.service.quicksettings.Tile
|
|
|
import android.service.quicksettings.TileService
|
|
|
import android.view.WindowManager.BadTokenException
|
|
|
import androidx.annotation.RequiresApi
|
|
|
-import androidx.core.os.postDelayed
|
|
|
import io.legado.app.R
|
|
|
import io.legado.app.constant.IntentAction
|
|
|
import io.legado.app.utils.buildMainHandler
|
|
|
@@ -60,10 +60,12 @@ class WebTileService : TileService() {
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
|
|
val dialog = Dialog(this, R.style.AppTheme_Transparent)
|
|
|
dialog.setOnShowListener {
|
|
|
- WebService.startForeground(this)
|
|
|
- handler.postDelayed(1000) {
|
|
|
- dialog.dismiss()
|
|
|
+ try {
|
|
|
+ WebService.startForeground(this)
|
|
|
+ } catch (e: ForegroundServiceStartNotAllowedException) {
|
|
|
+ e.printStackTrace()
|
|
|
}
|
|
|
+ dialog.dismiss()
|
|
|
}
|
|
|
try {
|
|
|
showDialog(dialog)
|