Hi folks, i'm trying to use window manager only in...
# android
m
Hi folks, i'm trying to use window manager only in app activites. I dont want to get permission from user for this. Some of API devices it works without crash. In my device i'm starting the window manager service and putting a small view to screen and its staying all of activities as i wanted. When i throw the app to the background it's not showing and i want this so it's okay. But some of API for example 11.0 it throws an error for permission. Whatsapp doesn't even ask permission for video call. I dont know is it true way to do this but simply i have to create a view which can be draggable and must be appear all of activities in the app. and here is my code line
Copy code
windowManager = getSystemService(WINDOW_SERVICE) as WindowManager

val inflater = baseContext.getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater

floatView = inflater.inflate(R.layout.floating_layout, null) as ViewGroup

webView = floatView.findViewById(R.id.webView)!!

LAYOUT_TYPE = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
} else {
    WindowManager.LayoutParams.TYPE_TOAST
}

floatWindowLayoutParams = WindowManager.LayoutParams(
    150.toPx(baseContext),
    200.toPx(baseContext),
    LAYOUT_TYPE!!,
    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
    PixelFormat.TRANSLUCENT
)

floatWindowLayoutParams.gravity = Gravity.CENTER
floatWindowLayoutParams.x = 0
floatWindowLayoutParams.y = 0

windowManager.addView(floatView, floatWindowLayoutParams)
and when i want to start the view
Copy code
btnWebView.setOnClickListener {
    startService(Intent(this, FloatingWindowApp::class.java))
}
Can you help me ?
😶 3
K 3