@@ -283,6 +283,9 @@ public interface OnInterceptTouchListener {
283283 // Have we started yet?
284284 public boolean mStarted = false ;
285285
286+ // what is the textinput type while calling the keyboard
287+ public int inputType = EditorInfo .TYPE_CLASS_TEXT ;
288+
286289 // Is Python ready to receive input events?
287290 static boolean mInputActivated = false ;
288291
@@ -449,6 +452,12 @@ public static void setOpenFile(){
449452 }
450453 }
451454
455+
456+ public void closeSoftKeyboard (){
457+ // close the IME overlay(keyboard)
458+ Hardware .hideKeyboard ();
459+ }
460+
452461 /**
453462 * Inform the view that the activity is paused. The owner of this view must
454463 * call this method when the activity is paused. Calling this method will
@@ -457,6 +466,7 @@ public static void setOpenFile(){
457466 */
458467 public void onPause () {
459468
469+ this .closeSoftKeyboard ();
460470 synchronized (this ) {
461471 if (mPause == PAUSE_NONE ) {
462472 mPause = PAUSE_REQUEST ;
@@ -496,6 +506,7 @@ public void onResume() {
496506
497507 public void onDestroy () {
498508 Log .w (TAG , "onDestroy() called" );
509+ this .closeSoftKeyboard ();
499510 synchronized (this ) {
500511 this .notifyAll ();
501512
@@ -504,9 +515,6 @@ public void onDestroy() {
504515 return ;
505516 }
506517
507- // close the IME overlay(keyboard)
508- InputMethodManager inputMethodManager = (InputMethodManager )getContext ().getSystemService (Context .INPUT_METHOD_SERVICE );
509- inputMethodManager .hideSoftInputFromInputMethod (this .getWindowToken (), 0 );
510518
511519 // application didn't leave, give 10s before closing.
512520 // hopefully, this could be enough for launching the on_stop() trigger within the app.
@@ -1103,7 +1111,7 @@ public boolean onKeyPreIme(int keyCode, final KeyEvent event){
11031111 @ Override
11041112 public InputConnection onCreateInputConnection (EditorInfo outAttrs ) {
11051113 // setting inputtype to TYPE_CLASS_TEXT is necessary for swiftkey to enable
1106- outAttrs .inputType = EditorInfo . TYPE_CLASS_TEXT ;
1114+ outAttrs .inputType = inputType ;
11071115 // ask IME to avoid taking full screen on landscape mode
11081116 outAttrs .imeOptions = EditorInfo .IME_FLAG_NO_EXTRACT_UI ;
11091117 return new BaseInputConnection (this , false ){
0 commit comments