I have an activity with no child widgets for it and the corresponding xml file is,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
>
</LinearLayout>
and I want to open soft keyboard programmatically while the activity gets start.and what I've tried upto now is,
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
Give me some guidance.
I have used the following lines to display the soft keyboard manually inside the onclick event, and the keyboard is visible.
But I'm still not able to open this while the activity gets opened, so are there any solution for this?
In your manifest file, try adding the following to the
<activity>
that you want to show the keyboard when the activity starts:android:windowSoftInputMode="stateVisible"
This should cause the keyboard to become visible when the activity starts.
For more options, checkout the documentation.
This is the required source code :
For details , Please go through this link. This helped me. https://github.com/Nikhillosalka/Keyboard/blob/master/README.md
seems like this is working
seems this works better: in manifest:
seems the manifest working in android 4.2.2 but not working in android 4.0.3
in onCreate method of activity or onActivityCreated of a fragment
All I needed was to expose the keyboard, in a very precise moment. This worked for me! Thanks Benites.
And in the very precise moment: