0

There is a build-in function for hide keyboard in react-native call Keyboard.dismiss(), but what I wish is the native keyboard will disable during the app running.

**My app no have any TextInput, I using react-native-webview for entire layout

What I have try is add code below to AndroidManifest.xml

<activity android:name="com.your.package.ActivityName"
  android:windowSoftInputMode="stateHidden"  />
FeelRightz
  • 2,777
  • 2
  • 38
  • 73

1 Answers1

0

enter image description hereTry with this method....

   public static void hideSoftKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
    View view = activity.getCurrentFocus();
    if (view == null) {
        view = new View(activity);
    }
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

put above method in common class like CommonUtils call method in your activity's onCreate method

CommonUtils.hideSoftKeyboard(your_activity.this)

Hope this will work for you(this working perfectly for me).

pratik vekariya
  • 1,105
  • 1
  • 8
  • 14
  • where is CommonUtils ? i not android native developer, not understand where to put, can you explain how to add into react-native android – FeelRightz Jul 20 '20 at 10:56
  • @FeelRightz its just for example, you can add this method in your activity too. Just copy it from here and paste in your activity – pratik vekariya Jul 20 '20 at 11:30
  • @FeelRightz add this method at end of your activity. before last "}" . Check my edited answer, i have added image. if you see red text as per image, click on that text, it will ask for import and do import, your issue will be fix. – pratik vekariya Jul 20 '20 at 11:52
  • i using visual studio code for develop the app, can you share with me what namespace have been import ? – FeelRightz Jul 20 '20 at 12:58
  • @FeelRightz for visual studio i don't know, in android imports are as follows (1).import android.view.View; (2). import android.view.inputmethod.InputMethodManager; – pratik vekariya Jul 21 '20 at 03:36
  • it say error: cannot find symbol , and pointed to Activity – FeelRightz Jul 21 '20 at 17:10
  • @FeelRightz for visual studio i dont know exactly which import is correct. I mentioned in above comment is for android studio. – pratik vekariya Jul 22 '20 at 04:22