File tree Expand file tree Collapse file tree
app/src/main/java/xyz/tberghuis/floatingtimer/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,23 +6,25 @@ import android.view.ViewGroup
66import android.view.WindowManager
77
88class FtWindowManager (
9- private val service : FloatingService // context is really FloatingService
9+ private val service : FloatingService
1010) {
1111 private val windowManager = service.getSystemService(Context .WINDOW_SERVICE ) as WindowManager
1212
1313 private var callStartForegroundOnce = false
14-
14+
1515 // future.txt suspend withContext(Main)
1616 // wait till i write a test case to prove it will prevent ANR
1717 fun addView (view : View , params : ViewGroup .LayoutParams ) {
1818 windowManager.addView(view, params)
19- if (! callStartForegroundOnce){
19+ if (! callStartForegroundOnce) {
2020 callStartForegroundOnce = true
2121 // if I still get ForegroundServiceStartNotAllowedException
2222 // option are delay here, or override onWindowVisibilityChanged in AbstractComposeView
2323 // or override in View and have ComposeView child
2424 // https://developer.android.com/about/versions/15/behavior-changes-15
25- service.startInForeground()
25+ view.post {
26+ service.startInForeground()
27+ }
2628 }
2729 }
2830
You can’t perform that action at this time.
0 commit comments