How to clear focus of EditText under Fragment onResume() after manual input something in EditText
<p>I'm using a navigation drawer activity along with some fragments. I added some lines of code under onResume() on each fragment to go back a particular fragment by back button click. The code is:</p>

<pre><code>getView().setFocusableInTouchMode(true);
    getView().requestFocus();
    getView().setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP &amp;&amp; keyCode == KeyEvent.KEYCODE_BACK){
                Fragment fragment = null;
                Class fragmentClass;
                fragmentClass = Introduction.class;
                try {
                    fragment = (Fragment) fragmentClass.newInstance();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                FragmentManager fragmentManager = getFragmentManager();
                fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

                return true;
            }
            return false;
        }
    });
</code></pre>

<p>When I 1st open the fragment, the EditText will displayeing in Un Focused mode so if I click back button, it will working fine (because of :getView().setFocusableInTouchMode(true);). But suppose I write something in EditText and then click on back, can't go to previous fragment, rather it will close the app. What should I do?</p>