How can I read the color of the app below mine in an overlay app - Kotlin, Android

22 Views Asked by At

Currently I do:

  1. create a transparent widget
  2. create a bitmap (android.graphics.Bitmap)
  3. create a canvas (android.graphics.Canvas) with the bitmap
  4. draw the widget on the canvas.
  5. analyze the colors on the canvas.

-> it's currently white only, because my transparent widget always comes off as white on the canvas, whatever the color under it.

How should I proceed? Is it even possible? I am open to looking for colors around my Widget (in places where I don't have any widgets from my app) if necessary.

Here are my layout params (copy-pasted from an autoclicker app):

val overlayParam =
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
            } else {
                WindowManager.LayoutParams.TYPE_PHONE
            }
        params = WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            overlayParam,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT)
0

There are 0 best solutions below