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

Feature: Allow app to receive `KeyEvent` from Accessibility Service #19

Closed fahimfoysal2 closed 7 months ago

fahimfoysal2 commented 7 months ago

Feature Request

Thanks

X-SLAYER commented 7 months ago

The package already have this feature FlutterAccessibilityService.performAction check the example folder and you will find some code examples

fahimfoysal2 commented 7 months ago

The package already have this feature FlutterAccessibilityService.performAction check the example folder and you will find some code examples

Thanks for your quick reply.

Sorry, maybe I was not clear. By receiving key press events, I meant to receive callbacks via the following method

protected boolean onKeyEvent(KeyEvent event) { throw new RuntimeException("Stub!"); }

from AccessibilityService class for keys like volume up/volume down buttons.


I started the implementation by overriding the method in AccessibilityListener.java

@Override
protected boolean onKeyEvent(KeyEvent event) {
        HashMap<String, Object> eventData = new HashMap<>();
        eventData.put("keyCode", event.getKeyCode());
        eventData.put("action", event.getAction());
        // Add more properties as needed

        // Send the event data to Flutter

        return super.onKeyEvent(event);
}
X-SLAYER commented 7 months ago

Yes for the moment this feature is not implemented yet. maybe in the next versions or else any pull requests are welcomed

fahimfoysal2 commented 7 months ago

Yes for the moment this feature is not implemented yet. maybe in the next versions or else any pull requests are welcomed

If you can guide me, or suggest a flow for the implementation, I can try.

X-SLAYER commented 7 months ago

for the moment you can make some researches otherwise I can't help sorry until I find time to check the functionality