简体   繁体   English

Android锁定android中的主页按钮和后退按钮

[英]Android to lock the home button and back button in android

嘿我想制作一个应用程序,将在手机启动时启动,我能够这样做但我的问题是在启动时禁用“主页按钮”和“后退按钮”它应该只在我启用时启用点击我的活动按钮,这将是启动时的主屏幕,请帮帮我..

You have to make an intent-filter for BOOT_COMPLETED . 你必须为BOOT_COMPLETED制作一个intent-filter You can get the tutorials from here and here 您可以从这里这里获得教程

To disable HOME and BACK 禁用HOME和BACK

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 但是,如果您的应用程序没有运行,那么你就无法做到这一点,你怎么可以制作你的自定义启动器 ,因为你可以决定天气是否显示屏幕

OR 要么

You can disable the home key check here 您可以在此处禁用主页密钥检查

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM