Android: On Single back key press soft keyboard should be hidden and activity should be finished as well, how to make it possible?

Yes, you can. See my answer here: Intercept back button from soft keyboard.

Add onKeyListener to your EditText and catch back key event and finish your activity. See here.

Make sure to return false so Android continues to execute that process. – Thorben Apr 6 at 13:50 Can't get it... AFAIK android back hw key event couldn't be intercepted if soft keyboard is visible, we have tried to debug it.. but flow didn't reach to break point everytime the soft keyboard is visible. And I NEED TO OVERRIDE THIS.... – Prasham Trivedi Apr 6 at 14:49.

Yes, it is completely possible to show and hide the keyboard and intercept the calls to the back button. It is a little extra effort as it has been mentioned there is no direct way to do this in the API. The key is to override boolan dispatchKeyEventPreIme(KeyEvent) within a layout.

What we do is create our layout. I chose RelativeLayout since it was the base of my Activity. Inside our Activity we set up our input fields and call the setActivity(...) function.

Obviously, the initInputField() function sets up the input field. It also enables the enter key to execute the functionality (in my case a search). Anyway, here is my override of the RelativeLayout.

Unfortunately I can't take all the credit. If you check the Android source for the quick SearchDialog box you will see where the idea came from.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions