5

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?

user316117
  • 7,971
  • 20
  • 83
  • 158
  • "Is this a feature of KitKat" -- yes. It is the same recent-tasks list that you have had from long-pressing HOME since Android 1.0 (though the styling will differ based on Android version and possible manufacturer changes). – CommonsWare Feb 10 '15 at 16:15
  • Any way to intercept/override this? – user316117 Feb 10 '15 at 16:26
  • Not outside of a ROM mod, AFAIK. Or, to put it another way, if there *is* a way to interfere with it, that's a security flaw that would need to be addressed. Android 5.0 may be the right answer for you long-term, as it has special "pinning" modes that you can use for this sort of scenario. IMHO, nobody should be using a stock ROM for industrial-control scenarios anyway, as your needs differ from that of ordinary consumers and manufacturers of devices for ordinary consumers. – CommonsWare Feb 10 '15 at 16:34
  • like the home button this is controlled by the system – njzk2 Feb 10 '15 at 16:39

2 Answers2

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);
}
kagkar
  • 469
  • 5
  • 15
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

Community
  • 1
  • 1
Sipty
  • 1,159
  • 1
  • 10
  • 18
  • What EXACTLY (and I mean precisely) do you mean by "system controls"? We override other hardware buttons in our apps, for example the Back button, and we're using the stock ROM. – user316117 Feb 10 '15 at 16:25
  • I've had to deal with the same problem myself and was not able to override the multitask key. My assumption was that this applied to the back key as well. After some poking around, I found several links, which not only support my answer, but might be useful to you. I will edit them in shortly. :) – Sipty Feb 10 '15 at 16:32