-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
engineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallywaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
Description
This issue is about an issue with Flutter API in native Android code.
In FlutterNativeView.java there is a function called send(String channel, ByteBuffer message, BinaryReply callback):
public void send(String channel, ByteBuffer message, BinaryReply callback) {
if (!this.isAttached()) {
Log.d("FlutterNativeView", "FlutterView.send called on a detached view, channel=" + channel);
} else {
this.dartExecutor.send(channel, message, callback);
}
}As you can see, if the view is not attached, nothing happens. I think we should call callback with an error message or maybe return something from the function.
I faced this issue trying to call channel.invokeMethod("launch", type); — if the view is not attached, there is no way to react to that case. Even if you call channel.invokeMethod("launch", type, callback);, the callback will not return onError, because, as you saw, in the case when the view is not attached, nothing will happen.
Steps to Reproduce
You can face the issue, for example, in quick_actions plugin.
- Install the example app and run it on Android
- If you try to use the Shortcut item, it should work fine
- Now, open the app again, and click Back button
- Click the Shortcut icon again
As you can see, the quick action will not be called and the app will not be opened this time. The main issue here is that the quick_actions plugin tries to callchannel.invokeMethod("launch", type);, but the view has been already detached and the only thing that happens is"FlutterView.send called on a detached view, channel=message in Logcat. And there is no way to fix this behavior because there is no way to react to such a case.
Metadata
Metadata
Assignees
Labels
engineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallywaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds