Closed luiisca closed 5 months ago
before displaying anything over other apps I need to ensure the user explicitely grants the app with the required permission as per [android docs](https://developer.android.com/reference/android/provider/Settings#canDrawOverlays(android.content.Context).
So asked gpt for a code snippet as well as reviewed [this example repo](https://developer.android.com/reference/android/provider/Settings#canDrawOverlays(android.content.Context).
private fun checkPermission() {
if (!Settings.canDrawOverlays(this)) {
val intent = Intent(
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:$packageName")
)
startActivity(intent)
}
}
apparentely I need to use something called a service, a long running background operation. Created a simple service class and started it using startService
from a material themed LargeFloatingActionButton
. Services have a lifecycle just like activities, onCreate
(executed on the first call to startService
), onStartComand
(every time startService
is called), onDestroy
and onBind
inside a service I need to get the WindowManager
instance associated with a display, to do that:
createWindowContext
getSystemService
on that contexaccording to [the docs](https://developer.android.com/reference/android/view/WindowManager?hl=en) is better to use Presentation
. gotta check it out
LUI-369 research: look for an android api to display floating windows