如何忽视&QUOT按钮点击近期活动按钮和QUOT;在安卓3.0 [英] How to ignore button click of "Recent Activity Button" in android 3.0

查看:222
本文介绍了如何忽视&QUOT按钮点击近期活动按钮和QUOT;在安卓3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是自我解释。 我寻觅了很多,但无法找到的方式来处理最近的活动按钮点击。 我想从安卓3.0平板电脑的状态栏忽视最近的活动按钮硬件按钮的点击。

My question is self explanatory. I have searched a lot but could not found the way to handle Recent activity button click. I want to ignore the hardware button clicks of Recent Activity button from the status bar from android 3.0 tablet.

目前我已经试过到目前为止:

Currently what I have tried so far is:

public boolean onKeyDown(int keyCode, KeyEvent event) {

       if(keyCode == KeyEvent.KEYCODE_BACK) 
       { 
              return true;
       }
       // in the same way I have written it for KEYCODE_HOME
}

您可以告诉我,我应该怎么写来处理最近的活动按钮?

can you tell me what should I write to handle recent activity button?

请多关照。 :)

编辑:这是我现在都试过了。该KEY code_APP_SWITCH是行不通的。

This is what I have tried now. The KEYCODE_APP_SWITCH is not working.

public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.e("INSIDE", "LOCKDEMO");
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Log.e("KEY EVENT", "BACK");
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_HOME) {
            Log.e("KEY EVENT", "HOME");
            return true;
        }
        if(keyCode == KeyEvent.FLAG_FROM_SYSTEM) {
            Log.e("KEY EVENT", "SYSTEM");
            return true;
        }
        if(keyCode == KeyEvent.FLAG_KEEP_TOUCH_MODE) {
            Log.e("KEY EVENT", "TOUCH MODE");
            return true;
        }
        if(keyCode == KeyEvent.FLAG_SOFT_KEYBOARD) {
            Log.e("KEY EVENT", "SoFT KEYBOARD");
            return true;
        }
        if(keyCode == KeyEvent.FLAG_VIRTUAL_HARD_KEY) {
            Log.e("KEY EVENT", "HARDWARE KEY");
            return true;
        }
        if(keyCode == KeyEvent.KEYCODE_APP_SWITCH) {
            Log.e("KEY EVENT", "APP SWITCH");
            return true;
        }

        Log.e("KEY EVENT", "NOT HANDLED");
        return super.onKeyDown(keyCode, event);
    }

当I $上RecentAppBtn p $ PSS,它甚至不打印,即事件不处理的最后一个日志声明。

When I press on RecentAppBtn, it does not even print the last Log statement i.e. Event not handled.

推荐答案

从窥视到的文档,我认为的 KeyEvent.KEY code_APP_SWITCH 是你要搜索的内容。

From peeking into the docs, I think that KeyEvent.KEYCODE_APP_SWITCH is what you're searching for.

您可以但是也可以使用 KeyEvent.getKey code() -method (在事件 -parameter)看其中键盘 - code被触发(如果有任何键触发),当你preSS的应用程序切换。

You could however also use the KeyEvent.getKeyCode()-method (on the event-parameter) to see which key-code is triggered (and if there is any key triggered), when you press the application switcher.

我研究了一下这一段时间,我已经得出结论,这是不可能的。

I played around with this for a while and I have come to the conclusion, that it's not possible.

键code_APP_SWITCH -event不传递为<一个href="http://developer.android.com/reference/android/app/Activity.html#onKeyDown%28int,%20android.view.KeyEvent%29"相对=nofollow> 的onkeydown() 也不<一href="http://developer.android.com/reference/android/app/Activity.html#dispatchKeyEvent%28android.view.KeyEvent%29"相对=nofollow> dispatchKeyEvent() 。测功,它不能被处理。

The KEYCODE_APP_SWITCH-event is not delivered to either onKeyDown() nor dispatchKeyEvent(). Ergo, It can not be handled.

此外,你在Android上遇到问题4的设备,因为的 键code_HOME -event 也不再派遣任何上述方法。请参阅该文档:

Also, you'll run into problems on Android 4 devices, because the KEYCODE_HOME-event is also no longer dispatched to any of the above methods. See the docs:

键code常数:Home键。这关键是由框架处理   并且永远不会传递给应用程序

Key code constant: Home key. This key is handled by the framework and is never delivered to applications.

这似乎也没有真正容易的方法来创建一个真正的锁屏自己。看到这个讨论:<一href="http://stackoverflow.com/questions/5529608/android-how-to-develop-custom-lock-screen">Developing自定义锁屏


It also seems that there is no real easy approach to creating a real lock-screen yourself. See this discussion: Developing a custom lock screen

这是非常可能的,以显示默认锁屏上的一些自定义的信息:<一href="http://stackoverflow.com/questions/6920613/is-there-a-way-for-me-to-show-a-customized-message-on-the-lock-screen/6920663#6920663">Is有没有办法对我来说,显示在锁定屏幕上的自定义消息?

It is well possible to show some custom information on the default lock-screen: Is there a way for me to show a customized message on the lock screen?

有关完整的缘故:在Android中L,你就可以锁定用户在应用程序中,所以你不需要手动覆盖硬件密钥。这里的相关信息的:

For the sake of completeness: In Android L, you'll be able to "lock users in your app", so you don't need to manually override the Hardware keys. Here's the relevant information:

第l开发preVIEW 引入了一个新的任务锁定的API,可以让   你暂时离开你的应用程序或成为限制用户   通过通知中断。这可以用来,例如,如果   正在开发的教育应用程序,以支持高风险评估   要求在Android上。 一旦你的应用程序激活此模式下,用户会   无法看到通知,访问其他应用程序,或返回   主屏幕,直到你的应用程序退出模式。

The L Developer Preview introduces a new task locking API that lets you temporarily restrict users from leaving your app or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android. Once your app activates this mode, users will not be able to see notifications, access other apps, or return to the Home screen, until your app exits the mode.

这篇关于如何忽视&QUOT按钮点击近期活动按钮和QUOT;在安卓3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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