How to ignore button click "Last activity button" in android 3.0

My question is on its own. I searched a lot, but could not find a way to handle the recent activity button. I want to ignore the clicks of the button on the "Recent Action" button on the toolbar from the status bar on the Android 3.0 tablet.

Currently, I have tried so far:

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 to write to handle the last activity button?

Thank you in advance. :)

EDIT: This is what I tried now. KEYCODE_APP_SWITCH does not work.

 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); } 

When I click on RecentAppBtn, it doesn't even print the last log statement, i.e. event is not processed.

+2
android android-3.0-honeycomb statusbar
Aug 20 2018-12-12T00:
source share
2 answers

From looking at the docs, I think KeyEvent.KEYCODE_APP_SWITCH is what you are looking for.

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




I played with this for a while, and I came to the conclusion that this is impossible.

KEYCODE_APP_SWITCH -event is not delivered to either onKeyDown() or dispatchKeyEvent() . Ergo, Unable to process.

In addition, you will run into problems on Android 4 devices because KEYCODE_HOME -event also no longer sends the above methods. See Documents:

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




It also seems that there is no real easy approach to creating a real lock screen. See Discussion: Designing a Custom Lock Screen

You can show some user data on the lock screen by default: Is there a way to show a customized message on the lock screen?




For completeness: in Android L you can "block users in your application", so you do not need to manually override the hardware keys. Here is the relevant information :

L Developer Preview introduces a new task blocking API that allows you to temporarily prevent users from leaving your application or is interrupted by notifications. This can be used, for example, if you are developing an educational application to support the evaluation of high rates requirements for Android. Once an application activates this mode, users will not be able to see notifications, access other applications, or return to the Home screen until your application exits the mode.

+6
Aug 20 2018-12-12T00:
source share

If you want to run a kiosk-based application, then you can disable com.android.systemui and replace the buttons with soft buttons (for example, the Button Savior application, although be careful not to brick your device!). It seems that a lot of cosmetic things are disappearing, and I do not know if this affects the stability of the system in some unknown way, but I have done so far.

If someone knows more about com.android.systemui , what he really does, and if you can turn it off, please comment!

Also see my post: Is it safe to disable com.android.systemui?

where I hope to get answers ...

+1
Mar 24 '15 at 10:39
source share



All Articles