Commit 2a412eb94c31b2aa7ba36e7a713f665db8352b39

Sylvain Becker 2018-12-30T15:39:37

Fixed bug 3186 - Android SW keyboard not restored when app becomes foreground.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index caa9b47..e93702b 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -805,6 +805,13 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)(
     __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeResume()");
 
     if (Android_Window) {
+
+        /* Make sure SW Keyboard is restored when an app becomes foreground */
+        if (SDL_IsTextInputActive()) {
+            SDL_VideoDevice *_this = SDL_GetVideoDevice();
+            Android_StartTextInput(_this); /* Only showTextInput */
+        }
+
         SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
         SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
         SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);