Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 opened this issue Mar 12, 2024 · 0 comments

Comments

@adityaiueo
Copy link

adityaiueo commented Mar 12, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant