本文介绍了如何preSS后退按钮在Android的编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我我的应用程序,我有一个注销功能。如果用户点击退出它进入家庭screen.Now我离开我的应用程序由pressing后退按钮。但是,我想是我需要自动退出(即通过编程)为同样喜欢后退按钮功能。我知道,通过调用完成()会做的功能。但事实是它去到previous活动。

I my app i have a logout functionality. If user clicks logout it goes to home screen.Now i am exiting my app by pressing back button. But what i want is i need to exit automatically(i.e Programatically) as same like as back button functionality. I know by calling finish() will do the functionality. But the thing is it goes to the previous activity.

感谢您的帮助球员

推荐答案

onBack pressed()支持自:API级别5

onBackPressed() is supported Since: API Level 5

 @Override
        public boolean onKeyDown(int keyCode, KeyEvent event) {
            if ((keyCode == KeyEvent.KEYCODE_BACK)) {
                onBackPressed();
            }
    }

@Override
    public void onBackPressed() {
        super.onBackPressed();   
        //    finish();

    }

这篇关于如何preSS后退按钮在Android的编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 22:46