i am trying to open keyboard when i move to first activity to second activity.
There is two button in main activity
1) if click on “NotShowKeyboard” button it will open the second.java activity with out keyboard
2) if s”ShowKeyboard” button is clicked then it will open the second.java activity with keyboard and EitdText with focus
But problem is that i don’t know how to do that. I put some examples top show keyboard but on “ShowKeyboard” button click keyboard open and immediately disappear.
Main.java:
NotShowKeyboard.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
}
if (event.getAction() == MotionEvent.ACTION_UP) {
bundle.putBoolean("show", false);
Intent start = new Intent(Main.this, Start.class);
start.putExtras(bundle);
startActivity(start);
}
return false;
}
});
ShowKeyboard.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
}
if (event.getAction() == MotionEvent.ACTION_UP) {
bundle.putBoolean("show", true);
Intent start = new Intent(Main.this, Start.class);
start.putExtras(bundle);
startActivity(start);
}
return false;
}
});
Second.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
i = getIntent();
extras = i.getExtras();
search = (EditText) findViewById(R.id.start_edit);
search.addTextChangedListener(myTextWatcher);
if((extras.getBoolean("show"))==true) {
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
//getting all stuff like buttons imageViews etc..
}
When NotShowButton Clicked then this should open:

When ShowButton Clicked then this should open:

Have you tried this?
Try and put this code in
onResume()