flutter_overlay_window icon indicating copy to clipboard operation
flutter_overlay_window copied to clipboard

Overlay Window doesn't disappear when app is in kill state

Open nahit-fidanci-alg opened this issue 1 year ago • 2 comments

Hi everyone,

I show overlay window when the app is in the background. And hide it when the app is foreground. At this point, it works well. But when the app is in the background, after the overlay window is shown, if I kill the app, the overlay window stays. And also my app is still working on the overlayMain(). Overlay window doesn't go anywhere until I purposely stop the app on IDE.

What I did

I try to use AppLifecycleState to close overlay on detached state. Even if I can catch the state and run closeOverlay function, nothing happens at all. I tried to use Isolates. Send an event called killOverlay to do the killing staff in overlay window widget. But it didn't work either.

I couldn't find a similar issue on the repo. Do you know if this is a known case? Any workaround to kill the overlay will be great.

nahit-fidanci-alg avatar Aug 13 '24 11:08 nahit-fidanci-alg

It seems that overlay runs on a different isolate on DartVM. Only way to stop it to exit(0) the app. Is there any other solution to stop overlay window without killing the DartVM?

nahit-fidanci-alg avatar Sep 03 '24 13:09 nahit-fidanci-alg

All below lines in MainActivity.kt.

override fun onDestroy() { super.onDestroy() if (OverlayService.isRunning) { stopService(Intent(this, OverlayService::class.java)) } Log.d("Lifecycle", "onDestroy") }

sikandersaleem avatar Oct 11 '24 19:10 sikandersaleem