From 5755e8b9563f834edfd74a08da672b83e39f9452 Mon Sep 17 00:00:00 2001 From: Rafael Ring Date: Tue, 11 Dec 2018 03:01:12 -0200 Subject: [PATCH] Fix keyboard not showing for targetSdk 28 (flutter/engine#6985) After bumping the targetSdk of Flutter apps to 28, the keyboard doesn't open anymore when inputting text on an Android Pie devices. The problem is caused by a change on the way the focus in handled: when the call `mImm.showSoftInput(view, 0);` is made, the currently focused view is the `DecorView` from the `Activity` hosting Flutter but the passed view reference (`view` argument) is the `FlutterView`. As the `InputMethodManager` checks if both views are the same before showing the keyboard, it never appears because the `FlutterView` never has focus. As Flutter doesn't have any input views as far as the Android side is concerned, the focus should always stay on the `FlutterView` itself and thus, this PR changes the `TextInputPlugin` to focus on the `FlutterView` as soon as it's created, fixing the keyboard issue. Co-authored-by: Igor Borges --- .../android/io/flutter/plugin/editing/TextInputPlugin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java index cd7282f87b..c59ee25148 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java @@ -167,6 +167,7 @@ public class TextInputPlugin implements MethodCallHandler { } private void showTextInput(FlutterView view) { + view.requestFocus(); mImm.showSoftInput(view, 0); }