Alexander Stolz
Alexander Stolz

Reputation: 7544

Turn off or modify recent apps list

Is there way to interact with the recent apps list which appears when you long press the home button? I would like to turn it off completely or if that is not possible to clear the entries.

Upvotes: 0

Views: 5970

Answers (3)

Quintin B
Quintin B

Reputation: 5881

The best way I have found is to do this:

public class BaseActivity extends Activity {
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);

            Log.d("Focus debug", "Focus changed !");

        if(!hasFocus) {
            Log.d("Focus debug", "Lost focus !");

            Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
            sendBroadcast(closeDialog);
        }
    }
}// all credit goes here: http://www.juliencavandoli.com/how-to-disable-recent-apps-dialog-on-long-press-home-button/

This is not my own code, but this just hides the recent apps list from showing. Anything else, like this: Android, how to clear the recent task list which could get from Home button in most phone? Reflection is a possible way?

requires a root or something else

Upvotes: 0

jcavandoli
jcavandoli

Reputation: 297

You have to listen on the focus of your activity :

When your activity is loosing focus, fire an Intent.ACTION_CLOSE_SYSTEM_DIALOGS intent.

More infos and sample code here : link

Upvotes: 1

SteD
SteD

Reputation: 14027

I'm not too sure if you could turn it off completely, but if you just want to exclude your app from appearing there, you could set android:excludeFromRecents="true" in your manifest.xml.

Have a look at getRunningTasks of ActivityManager to get a list of recently launched app.

public List getRunningTasks (int maxNum)

Return a list of the tasks that are currently running, with the most recent being first and older ones after in order. Note that "running" does not mean any of the task's code is currently loaded or activity -- the task may have been frozen by the system, so that it can be restarted in its previous state when next brought to the foreground.

At last, this question and answer provides some information regarding overriding the longpressed home button.

Upvotes: 5

Related Questions