1@Override
2public void onResume() {
3 super.onResume();
4
5 getView().setFocusableInTouchMode(true);
6 getView().requestFocus();
7 getView().setOnKeyListener(new View.OnKeyListener() {
8 @Override
9 public boolean onKey(View v, int keyCode, KeyEvent event) {
10 if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
11 // handle back button's click listener
12 Toast.makeText(getActivity(), "Back press", Toast.LENGTH_SHORT).show();
13 return true;
14 }
15 return false;
16 }
17 });
18
19}
20