禁用 Nexus 7 上的所有主页按钮和任务栏功能 [英] disable all home button and task bar features on Nexus 7

查看:39
本文介绍了禁用 Nexus 7 上的所有主页按钮和任务栏功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个将成为展览一部分的应用程序.它将显示在牢固安装的 Nexus 7 上.该应用程序具有触摸屏功能,并将显示交互式内容.

I am building an app that will form part of an exhibition. It will be displayed on a Nexus 7 which will be securely mounted. The app has touchscreen functionality and will display interactive content.

我需要能够在展示时禁用尽可能多的功能,因为我不希望公众能够访问应用程序以外的任何内容.

I need to be able to disable as many features as possible whilst on display as I do not want the public to be able to get to anything other than the app.

我正在努力解决的主要问题是返回/主页/最近的应用列表按钮.我发现了一些禁用主页按钮的示例(儿童锁 Android - 是否可以禁用点击主页按钮) 但理想情况下,我需要使按钮不可见,因此关闭发光"(黑色就可以).

The main thing I am struggling with is the back/home/recent app list button. I have found some examples of disabling home button (child lock Android - Is It possible to disable the click of home button ) but ideally I need the buttons to be invisible, so to turn off the 'glow' (black would be fine).

Nexus 7 的底部是否以某种方式受到保护,是否有其他版本的 Android 允许我这样做?Nexus 设备仅用于显示此应用,不需要其他功能.

Is the bottom section on a Nexus 7 protected in some way, is there another version of Android that would allow me to do this? The Nexus device will only be used for displaying this app, no other functionality is needed.

任何建议都会非常好,非常感谢.

Any suggestions would be great and very much appreciated.

推荐答案

在不创建自己的自定义 Android rom 来移除底部按钮的情况下,您最好的解决方案是让应用全屏,覆盖后退按钮,并让您的应用启动器以覆盖主页按钮.

Your best solution without creating your own custom Android rom to remove the bottom buttons, will be to make the app full screen, override the back button, and make your app a launcher in order to override the home button.

AFAIK,没有办法覆盖最近的应用程序按钮.

AFAIK, there is no way of overriding the recent apps button.

另一种选择是拥有一个全屏应用,然后使用覆盖按钮的支架.(感谢 MaciejGórski 的想法).

One other option would to have a fullscreen app and then use a mount that will cover the buttons. (Thanks to MaciejGórski for the idea).

要让您的应用全屏显示,请将以下内容放入 Activity 的 onCreate():

To make your app full screen, put the following in your activity's onCreate():

requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

或者您也可以在清单中使应用全屏显示,这要感谢@Niels:

Or you can make the app full screen from within the manifest as well, thanks to @Niels:

<application android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">

要覆盖后退按钮,请添加此方法:

To override the back button, add this method:

@Override
public void onBackPressed() {
    return;
}

现在主页按钮更复杂了,将以下内容添加到您的清单中:

Now the home button is trickier, add the following to your manifest:

 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

并将其添加到 <activity> 下的清单中:

and this to your manifest under the <activity>:

<intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<application> 下的清单中,请确保 <receiver name> 是您定义的完整包名称路径:

and this to your manifest under the <application>, make sure that the <receiver name> is the full package name path you define:

<receiver android:name="com.example.BootCompleteReceiver">
   <intent-filter>  
        <action android:name="android.intent.action.BOOT_COMPLETED" />
   </intent-filter>
</receiver>

最后,创建一个名为 BootCompleteReceiver 的 java 类文件,并使用以下代码:

And lastly, create a java class file called BootCompleteReceiver, and use this code:

public class BootCompleteReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
    Intent startActivityIntent = new Intent(context, YourActivityName.class);
    startActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(parentActivityIntent);
  }
}

要稍后禁用您的应用作为主屏幕启动器,请按最近使用的应用按钮,从右侧向下滑动,点按设置,转到应用,然后点按右上角的三个点(垂直对齐),按重置应用首选项",然后最后按重置应用程序".

To later disable your app as a home screen launcher, press the recent app button, swipe down from the right side, tap settings, go to apps, then tap the upper right three dots (vertically aligned), press "Reset app preferences", and then finally press "Reset apps".

我认为这应该涵盖所有内容.

I think that should just about cover it all.

编辑 2 我刚刚意识到/测试过,如果您将应用程序设为启动器,则不一定需要 BOOT_COMPLETED 意图.这意味着不需要 BootComplete.java.您可以只使用包含 MAIN、HOME 和 DEFAULT 属性的 <intent-filter>.

EDIT 2 I just realized/tested and you do NOT necessarily need the BOOT_COMPLETED intent if you make your application a launcher. This means that the <uses-permission>, <receiver>, and BootComplete.java are not needed. You can just use the <intent-filter> that includes the MAIN, HOME, and DEFAULT attributes.

编辑 3 更多/不同的信息可在此处获得:Home Launcher 重启后片段出现问题

这篇关于禁用 Nexus 7 上的所有主页按钮和任务栏功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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