Arun Badole
Arun Badole

Reputation: 11097

Problem in using keyboard's Back button in Android

I am creating an Android application in my application all Activities (pages) have a Back button so by pressing I can go to previous page or another page.For going on another page I use startActivity() and finish().But when I press keyboard's Back Button it goes to page which was previously pushed in Activities Stack.And I want to synchronize Keyboard's Back button and My Activities Back button.

How can I do this Please Help..

Upvotes: 0

Views: 544

Answers (1)

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK)
        {
            //start youractivity or finish();
        }
        return super.onKeyDown(keyCode, event);
    }

override this method on your activity

Upvotes: 2

Related Questions