From cf883b5c0f8c77630f0a086daac3c08cba7e6073 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 May 2016 12:02:23 +0800 Subject: [PATCH] UI thread check. --- .../java/src/org/cocos2dx/lib/Cocos2dxEditBoxHelper.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxHelper.java index 650ea1329b..bc61a28dfb 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxHelper.java @@ -28,6 +28,7 @@ import android.content.Context; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Typeface; +import android.os.Looper; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; @@ -394,6 +395,11 @@ public class Cocos2dxEditBoxHelper { } private static void closeKeyboardOnUiThread(int index) { + if (Looper.myLooper() != Looper.getMainLooper()) { + Log.e(TAG, "closeKeyboardOnUiThread doesn't run on UI thread!"); + return; + } + final InputMethodManager imm = (InputMethodManager) mCocos2dxActivity.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); Cocos2dxEditBox editBox = mEditBoxArray.get(index); if (null != editBox) {