Android implementing onBackPress on Fragment cause of disable exit from application
<p>In my application i have some fragment and i can exit from application by click on back on phone without problem, but when i implementing <code>onBackPress</code> on that i can't exit from application</p>

<p>My code:</p>

<pre><code>@Override
public void onResume() {
    super.onResume();
    if (getView() == null) {
        return;
    }
    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) {
                if (slider_call_phones.isOpened()) {
                    slider_call_phones.closeLayer(true);
                }
                return true;
            }
            return false;
        }
    });
}
</code></pre>

<p>I want to handle <code>onBackPressed</code> on fragment not Activities</p>