The back button of the device does not work when you place a location on the Google map fragment

advertisements

What i did: I had added a map fragment on my screen to locate the entered location from edittext box to the map. Before locating the location, if i press back button, it works smooth. But after locating the location on google map fragment, onBackPressed does not work.

What i want: i want my device physical back button to work as default.

I am locating the place on map fragments on keyboard enter press button.
Any solution/idea will be highly appreciated.

Thanks !

**EDIT:: ** this is what i had done:

myEditTextBox.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                    case KeyEvent.KEYCODE_DPAD_CENTER:
                    case KeyEvent.KEYCODE_ENTER:
// My code here...
            return true;
        }
    });

and this is my onBackPressed() :

  @Override
public void onBackPressed() {
    super.onBackPressed();
    startActivity(mtIntent to call another activity);
}


onKey() method, return true only inside the IF bloc otherwise return false.

You should return true if you handled the event but if you want the event to be handled by the next receiver, return false.