开发者

Problem in using keyboard's Back button in Android

开发者 https://www.devze.com 2023-04-04 23:24 出处:网络
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(

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..


@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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号