Try catch popupKeyboard to avoid rare crashes. Add more exception logging.
@@ -62,7 +62,8 @@ import android.text.TextWatcher;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONException;
-
+import java.io.StringWriter;
+import java.io.PrintWriter;
public class GameActivity extends ::GAME_ACTIVITY_BASE::
implements SensorEventListener
@@ -297,7 +298,7 @@ implements SensorEventListener
result = array.toString();
} catch (JSONException e) {
- e.printStackTrace();
+ Log.e(TAG, getStackTrace(e))
responseCode = -1;
}
@@ -1175,13 +1176,26 @@ implements SensorEventListener
public static void popupKeyboard(final int inMode, final String inContent, final int inType)
{
- if(activity == null) {
- Log.i("VIEW","popupKeyboard occured after destruction, ignoring...");
- return;
+ try {
+ activity.mHandler.post(new Runnable() {
+ @Override public void run() {
+ try {
+ handlePopKeyboard(inMode, inContent, inType);
+ }
+ catch(Exception e) {
+ Log.e(TAG, getStackTrace(e));
+ Log.e(TAG,"handlePopKeyboard: " + e);
+ }
+ }
+ });
+ }
+ catch(Exception e) {
+ Log.e(TAG, getStackTrace(e));
+ Log.e(TAG,"popupKeyboard: " + e);
+ }
}
- activity.mHandler.post(new Runnable() {
- @Override public void run()
+ private static void handlePopKeyboard(final int inMode, final String inContent, final int inType)
{
InputMethodManager mgr = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(activity.mView.getWindowToken(), 0);
@@ -1227,7 +1241,6 @@ implements SensorEventListener
// On the Droid SHOW_IMPLICIT doesn't bring up the keyboard.
activity.mTextUpdateLockout = false;
}
- }} );
}
@@ -1434,6 +1447,14 @@ implements SensorEventListener
String action = intent.getAction();
return intent.getData();
}
+
+ private static String getStackTrace(Exception e)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ e.printStackTrace(pw);
+ return sw.toString();
+ }
}
