Android的锁定HOME键和后退按钮android中 [英] Android to lock the home button and back button in android

查看:867
本文介绍了Android的锁定HOME键和后退按钮android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我想打一个应用程序,它会开始的时候,手机就会开始,这我能够这样做,但我的问题是禁用的主页按钮&放大器; 后退按钮上启动了一个只应使当我点击我的活动的按钮,将在启动时的主屏幕,请帮助我。

hey i want to make an Application which will start when the phone will start, which i am able to do so but my problem is to disable the "Home Button" & "Back Button" on start up an it should only be enable when i click an button on my activity which will be the home screen on start up, please help me out..

推荐答案

您必须做出一个意图过滤器 BOOT_COMPLETED 。你可以从这里和<一个教程href="http://stackoverflow.com/questions/10428510/how-to-start-launch-application-at-boot-time-android">here

You have to make an intent-filter for BOOT_COMPLETED. You can get the tutorials from here and here

要禁用HOME和返回

让SE ... 如果您的应用程序正在运行,可见用户,那么你可以做到这一点通过以下code

Lets se... If your app is running and visible to user then you can do that by using the following code

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR
        && (keyCode == KeyEvent.KEYCODE_BACK    || keyCode == KeyEvent.KEYCODE_HOME)
    && event.getRepeatCount() == 0) 
    {
        onBackPressed();
    }
    return super.onKeyDown(keyCode, event);
}

@Override
public void onBackPressed() {
    // Do nothing
    return;
}

但是,如果你的应用程序没有运行,那么它是不可能为你做的怎么过,你可以让你的自定义启动的在那韦,你可以决定的天气显示在屏幕或不

But if your app is not running then it is not possible for you to do that how ever you can make your custom launcher in that wey you can decide weather to show the screen or not

您可以禁用home键检查这里

You can disable the home key check here

这篇关于Android的锁定HOME键和后退按钮android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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