X-SLAYER / flutter_accessibility_service

Flutter plugin for interacting with Accessibility Service in Android.
https://pub.dev/packages/flutter_accessibility_service
MIT License
33 stars 24 forks source link

[Android 14] Required RECEIVER_NOT_EXPORTED/RECEIVER_EXPORTED #13

Closed sarthakydv closed 9 months ago

sarthakydv commented 9 months ago

Required param for support on android 14.

Discussion: https://stackoverflow.com/questions/77235063/one-of-receiver-exported-or-receiver-not-exported-should-be-specified-when-a-rec

sarthakydv commented 9 months ago

I have added a fix in a private fork. I can't make a branch here. Here are the changes:

  1. android/build.gradle compileSdkVersion 31 -> 34 (so that the latest APIs are available)
  2. android/src/main/java/slayer/accessibility/service/flutter_accessibility_service/FlutterAccessibilityServicePlugin.java

add imports:

import android.annotation.SuppressLint;
import android.os.Build;

Annotate onListen with @SuppressLint("WrongConstant") - the lint is giving a false warning. I have reported it.

Replace context.registerReceiver(accessibilityReceiver, intentFilter); with

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
                context.registerReceiver(accessibilityReceiver, intentFilter, Context.RECEIVER_EXPORTED);
            }else{
                context.registerReceiver(accessibilityReceiver, intentFilter);
            }
X-SLAYER commented 9 months ago

I will try that otherwise try to make a pull request directly

sarthakydv commented 9 months ago

Please do it, we are only managing our private fork

X-SLAYER commented 9 months ago

a new version i published suppor android 14 + new core features flutter_accessibility_service 0.2.3