I am following below code:-

```
 @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // handle arrow click here
        if (item.getItemId() == android.R.id.home) {

            finish();
            overridePendingTransition(R.transition.right_in, R.transition.right_out);

        }
        return super.onOptionsItemSelected(item);
    }

```

In this when my keyboard is open and I press my toolbar back arrrow ,the keyboard remain open and activity got finish. I have tried forcefully hiding keyboard in on pause() by callling below method but doesn't look good while transition :-

```
public static void hideKeyboard(Activity activity) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
        //Find the currently focused view, so we can grab the correct window token from it.

        View view = activity.getCurrentFocus();
        //If no view currently has focus, create a new one, just so we can grab a window token from it
        if (view == null) {
            view = new View(activity);
        }
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);

    }

```