问题
We have an industrial control app we write and ship pre-loaded on Samsung Galaxy Tablets with our manufacturing products.
The tablets we were using were Tab 10's which ran Honeycomb, but we can't get enough of those to OEM anymore so we're switching to Tab 4's which run KitKat. The new tablets have a button which looks like the old menu button - two overlapping rectangles - but it's different functionality - it's called the "multi-task" button and it brings up a task-switcher/task-killer.
We'd like to programmatically disable that or override it with different behavior. How do we do that? Is this a feature of KitKat, or is it a Samsung customization that we can't get programmatic access to?
回答1:
As far as I know -- no, you are not allowed to override system controls from an app.
You can probably achieve this with a ROM mod though. : )
Here are a few related links:
Android Override multitasking-key
How to ignore button click of “Recent Activity Button” in android 3.0
回答2:
This code works for me. Actually, you cannot disable task button. When you press it, your activity calls onPause()
method and you can move your task to the front in this method. See my answer for related question.
@Override
protected void onUserLeaveHint() {
super.onUserLeaveHint();
((ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE)).moveTaskToFront(getTaskId(), 0);
}
@Override
protected void onPause() {
super.onPause();
((ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE)).moveTaskToFront(getTaskId(), 0);
}
来源:https://stackoverflow.com/questions/28436357/any-way-to-disable-override-the-mutitask-button-on-galaxy-tab-4