覆盖的背部和家按钮的功能 [英] Overriding the functionality of back and home buttons

查看:114
本文介绍了覆盖的背部和家按钮的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以覆盖返回家居按钮(硬件)在 Android的功能?我的意思是像点击主页按钮应该去家里我的应用程序的屏幕而不是家手机屏幕

Can i override the functionality of back and homebuttons(hardware) in android? i mean like clicking on home button should go tohome screen of my app instead of home screen of mobile

推荐答案

主页按钮:

=>您不能覆盖​​的home键的行为。

=> You can't override the behaviour of home button.

返回按钮:

=>为了捕获或覆盖默认后退按钮preSS在安卓以下的onkeydown方法可以通过活动来实现。

=> In order to capture or override the default back button press in Android the following onKeyDown method can be implemented by the Activity.

 @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            moveTaskToBack(true);
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

在案件的Andr​​oid 2.0+一个说服的方法是作为

In case of Android 2.0+ a convince method is provided as

  @Override
    public void onBackPressed() {

        // implement your override logic here
       return;
    }

这篇关于覆盖的背部和家按钮的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆