From a80d2ee847b8b6bf62d864a5ba13bfae6b626424 Mon Sep 17 00:00:00 2001 From: mschiller890 Date: Wed, 11 Mar 2026 19:10:08 +0200 Subject: [PATCH] Fix NPE in MainActivity.onDialogCompleted by guarding showSoftInput call with null focus check --- .../com/mojang/minecraftpe/MainActivity.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/project/android/src/com/mojang/minecraftpe/MainActivity.java b/project/android/src/com/mojang/minecraftpe/MainActivity.java index 95f33f7..7b1e3ae 100755 --- a/project/android/src/com/mojang/minecraftpe/MainActivity.java +++ b/project/android/src/com/mojang/minecraftpe/MainActivity.java @@ -468,17 +468,16 @@ public class MainActivity extends NativeActivity { _userInputStatus = 1; InputMethodManager inputManager = (InputMethodManager)getSystemService("input_method"); - boolean result = inputManager.showSoftInput(this.getCurrentFocus(), InputMethodManager.SHOW_IMPLICIT); - } - - protected void onStart() { - //System.out.println("onStart"); - super.onStart(); - } - - protected void onResume() { - //System.out.println("onResume"); - super.onResume(); + View focused = this.getCurrentFocus(); + if (focused != null) { + boolean result = inputManager.showSoftInput(focused, InputMethodManager.SHOW_IMPLICIT); + } else { + // fallback: try to show using decor view token + View decor = getWindow().getDecorView(); + if (decor != null) { + inputManager.showSoftInput(decor, InputMethodManager.SHOW_IMPLICIT); + } + } } protected void onPause() {