Automatic popping up keyboard on start Activity
Use this attributes in your layout tag in XML file:
android:focusable="true"
android:focusableInTouchMode="true"
As reported by other members in comments it doesn't works on ScrollView
therefore you need to add these attributes to the main child of ScrollView
.
keyboard automatic pops up when moving from one activity to another
If you have tried everything that comes as an accepted ans according to your links for the ques, then why don't you try debugging your start activity, i mean on which you have put intent to start the respective activity.
While debugging one of my application i found that android soft keyboard has that problem of not going down even after finishing the activity that calls it, it stays on screen for few seconds but this doesn't happen frequently.
So i suggest you to debug your calling activity too just try putting "focusable=false" on the component from which you called the respective activity.
Prevent the keyboard from displaying on activity start
I think the following may work
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
I've used it for this sort of thing before.
Keyboard shows up automatically when the app starts?
In the AndroidManifest.xml you can use the following settings:
<activity android:name="com.your.package.ActivityName"
android:windowSoftInputMode="stateHidden" />
You can also try:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
You can find more details at this link.
OnScreen keyboard opens automatically when Activity starts
Android opens the OnScreenKeyboard automatically if you have an EditText
focussed when the Activity starts.
You can prevent that by adding following into your Activity's onCreate
method.
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
How to hide Soft Keyboard when activity starts
If you don't want to use xml, make a Kotlin Extension to hide keyboard
// In onResume, call this
myView.hideKeyboard()
fun View.hideKeyboard() {
val inputMethodManager = context.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(windowToken, 0)
}
Alternatives based on use case:
fun Fragment.hideKeyboard() {
view?.let { activity?.hideKeyboard(it) }
}
fun Activity.hideKeyboard() {
// Calls Context.hideKeyboard
hideKeyboard(currentFocus ?: View(this))
}
fun Context.hideKeyboard(view: View) {
view.hideKeyboard()
}
How to show soft keyboard
fun Context.showKeyboard() { // Or View.showKeyboard()
val inputMethodManager = context.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.toggleSoftInput(SHOW_FORCED, HIDE_IMPLICIT_ONLY)
}
Simpler method when simultaneously requesting focus on an edittext
myEdittext.focus()
fun View.focus() {
requestFocus()
showKeyboard()
}
Bonus simplification:
Remove requirement for ever using getSystemService
: Splitties Library
// Simplifies above solution to just
inputMethodManager.hideSoftInputFromWindow(windowToken, 0)
How to remove auto focus/keyboard popup of a field when the screen shows up?
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextField.getWindowToken(), 0);
or
set activity property in manifest file as below in the application tag
android:windowSoftInputMode="stateHidden"
How to keep soft keyboard from opening on activity launch in Android?
I know this is old but maybe it will help someone in the future...
I haven't seen anyone suggest "stateHidden"
From the Android docs - android:windowSoftInputMode
Your manifest file would look like:
<activity
...
android:windowSoftInputMode="stateHidden|adjustResize"
...
>
Related Topics
How to Serialize an Object of Android.Graphics.Path
Android Save Images to SQLite or Sdcard or Memory
How to Get Value of Some Field in Firebase Firestore Android
How to Pause Flash Content in an Android Webview When My Activity Isn't Visible
How to Know Which Intent Is Selected in Intent.Action_Send
Mediaplayer Error (1, -1004) Aka Media_Error_Io Trying to Stream Music on Samsung S3
Play Sound on Phonegap App for Android
Missing Styles. Is the Correct Theme Chosen for This Layout
Filter Output in Logcat by Tagname
Change Status Bar Color with Appcompat Actionbaractivity
Using JSON File in Android App Resources
Should I Use Android: Process =":Remote" in My Receiver
Position of Dialogfragment in Android
Android Studio Unit Testing: Read Data (Input) File
Cache Images Local, from Google Firebase Storage
Travis Ci Failed Because Cannot Accept License Constrain Layout