does android accessibilityService take screenshot work on api lower than 30?

Viewed 1386

I am using Android AccessibilityService to take screenshot using some method that has been added on api level 30 , I wonder to know if it works on api's lower than 30 or not

this is my overrided method


    @Override
    public void takeScreenshot(int displayId, @NonNull Executor executor, @NonNull TakeScreenshotCallback callback) {
        super.takeScreenshot(displayId, executor, callback);
    }

and this is where I call takeScreenshot method and it gives me the result by takeScreenshot CallBack


takeScreenshot(Display.DEFAULT_DISPLAY,
                getApplicationContext().getMainExecutor(), new TakeScreenshotCallback() {
            @RequiresApi(api = Build.VERSION_CODES.R)
            @Override
            public void onSuccess(@NonNull ScreenshotResult screenshotResult) {

                Log.i("ScreenShotResult","onSuccess");
                Bitmap bitmap = Bitmap.wrapHardwareBuffer(screenshotResult.getHardwareBuffer(),screenshotResult.getColorSpace());
                AccessibilityUtils.saveImage(bitmap,getApplicationContext(),"WhatsappIntegration");

            }

            @Override
            public void onFailure(int i) {

                Log.i("ScreenShotResult","onFailure code is "+ i);

            }
        });

1 Answers

Unfortunately, not. I tried to using it on APIs lower than 31 and got the following error.

enter image description here

here is my XML:

<accessibility-service
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:accessibilityEventTypes="typeAllMask"
    android:accessibilityFeedbackType="feedbackAllMask"
    android:notificationTimeout="100"
    android:canRetrieveWindowContent="true"
    android:canTakeScreenshot="true"/>
Related