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

NullPointerException when called after app is paused #7

Open
jinyus opened this issue Jan 9, 2021 · 0 comments
Open

NullPointerException when called after app is paused #7

jinyus opened this issue Jan 9, 2021 · 0 comments

Comments

@jinyus
Copy link

jinyus commented Jan 9, 2021

This plugin fails when attempting to read the clipboard after switching to another app.

Here is the stacktrace:

E/MethodChannel#flutter_clipboard_manager( 8348): Failed to handle method call
E/MethodChannel#flutter_clipboard_manager( 8348): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.ClipData.getItemCount()' on a null object reference
E/MethodChannel#flutter_clipboard_manager( 8348): 	at com.example.flutter_clipboard_manager.FlutterClipboardManagerPlugin.onMethodCall(FlutterClipboardManagerPlugin.java:49)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#flutter_clipboard_manager( 8348): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/DartMessenger( 8348): Uncaught exception in binary message listener
E/DartMessenger( 8348): java.lang.IllegalStateException: Reply already submitted
E/DartMessenger( 8348): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:139)
E/DartMessenger( 8348): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:253)
E/DartMessenger( 8348): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/DartMessenger( 8348): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/DartMessenger( 8348): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/DartMessenger( 8348): 	at android.os.MessageQueue.next(MessageQueue.java:336)
E/DartMessenger( 8348): 	at android.os.Looper.loop(Looper.java:174)
E/DartMessenger( 8348): 	at android.app.ActivityThread.main(ActivityThread.java:7356)
E/DartMessenger( 8348): 	at java.lang.reflect.Method.invoke(Native Method)
E/DartMessenger( 8348): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/DartMessenger( 8348): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Code to reproduce:

Timer.periodic(Duration(seconds:2), (_) async {
      final text = await FlutterClipboardManager.copyFromClipBoard();
      print('got clipboard data: $text');
    });

press go into recent screenpress home button on android so the app will be in the paused state.

kreativityapps pushed a commit to kreativityapps/flutter_clipboard_manager that referenced this issue Mar 8, 2021
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