简体   繁体   English

禁用Android主页按钮以用于行业应用程序

[英]Disabling Android home button for industry application

I'm writing an industry application which will be used by traffic wardens to register offences through my program using forms. 我正在编写一个行业应用程序,交通管理员将使用该表格通过我的程序注册违规行为。

The app is using a webview so it is just a container for an external webpage. 该应用正在使用webview,因此它只是外部网页的容器。 We don't want our users to exit the application so we have to disable all buttons. 我们不希望我们的用户退出应用程序,因此我们必须禁用所有按钮。 I succeeded in disabling them except for the home button. 除了主页按钮之外,我成功禁用了它们。

I read some threads about this topic, but I don't have any solutions yet. 我读了一些关于这个主题的线索,但我还没有任何解决方案。 The idea is that I am able to make the app the default home app so if the user presses the home button it launches my app and does not exit. 我的想法是,我能够将应用程序设置为默认的家庭应用程序,因此如果用户按下主页按钮,它将启动我的应用程序并且不会退出。 How can I accomplish that? 我怎么能做到这一点? If we must we are able to tamper with android itself (when we install the app), but if there is some solution through configuration it would be appreciated. 如果我们必须能够篡改Android本身(当我们安装应用程序时),但如果通过配置有一些解决方案,将不胜感激。

The idea is that I am able to make the app the default home app so if the user presses the home button it launches my app and does not exit. 我的想法是,我能够将应用程序设置为默认的家庭应用程序,因此如果用户按下主页按钮,它将启动我的应用程序并且不会退出。 How can I accomplish that? 我怎么能做到这一点?

There is a sample Home application in your Android SDK. 您的Android SDK中有一个示例Home应用程序。 Mirror its manifest entry, notably putting the HOME category in the activity's <intent-filter> . 镜像其清单条目,特别是将HOME类别放在活动的<intent-filter>

The first time the, er, traffic warden taps HOME after installing your app, a chooser will appear for which home app to run. 第一次,呃,交通督导员在安装你的应用程序后点击HOME,将出现一个选择器来运行哪个家庭应用程序。 Checking the checkbox and tapping your app will then mean the HOME button will run your app forevermore. 选中复选框并点按您的应用程序将意味着HOME按钮将永远运行您的应用程序。

Beyond creating a custom home app, though, there is no way to intercept the HOME button except through firmware modifications. 但是,除了创建自定义家庭应用程序之外,除了通过固件修改之外,无法拦截HOME按钮。

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    getWindow().addFlags(  WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

} }

@Override
public void onBackPressed() {

   return;
}

@Override
public void onAttachedToWindow()
{  

       this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
       super.onAttachedToWindow();

}

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

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