Skip to content

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.  #29

Open
@adityaiueo

Description

@adityaiueo

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:

  1. Install the flutter_accessibility_service package and follow the instructions in the README.
  2. 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;
    }
    
  3. Run the application on an emulator and enable accessibility permissions.
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions