flutter_accessibility_service
flutter_accessibility_service copied to clipboard
W/FlutterJNI(23350): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: x-slayer/accessibility_event.
Issue Description
Problem:
I am attempting to identify the currently active application using the Flutter Accessibility Service. After following the instructions provided on the package’s pub.dev page, I utilized event.packageName
to achieve this. However, upon implementing the code in my main.dart,
I encountered the following error:
W/FlutterJNI(23350): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: x-slayer/accessibility_event. Response ID: 131
This error occurs after my application is closed, and persists even when the application is reopened.
Steps to Reproduce:
-
Install the
flutter_accessibility_service
package and follow the instructions in theREADME.
-
I'm just adding the following damn code to the MyApp class in main.dart:
StreamSubscription<AccessibilityEvent>? _subscription; List<AccessibilityEvent?> events = []; String currentApp = ''; String getCurrentApp() { if (_subscription?.isPaused ?? false) { _subscription?.resume(); return ''; } _subscription = FlutterAccessibilityService.accessStream.listen((event) async { setState(() { currentApp = event.packageName!; }); log("current event : $currentApp"); }); return currentApp; }
-
Run the application on an emulator and enable accessibility permissions.
-
Close the app.
Expected Behavior: The getCurrentApp()
function should log the package name in the terminal, but it does not execute as expected, and no package name is logged.
Actual Behavior: The error message is displayed, and the expected behavior does not occur.
any idea how to fix it? your help is wanted! @X-SLAYER @fahimfoysal2 @avisihag Thank You