Pax Beach
Pax Beach

Reputation: 2793

Software deleting the Android application from the list of recent applications

What happens at the system level when we press hardware button "Recent apps", and at the "recent apps" window delete the app? At the user level, the application is removed from the list, if the application has been launched the service, it loses the application process and restarts.

I need to repeat this user action (removal of the program from the list of recent applications) by software from the itself application, with all the associated system procedures. Or delete from the list by another application.

Hiding the application through the Android-manifest (like android:excludeFromRecents) is not suitable.

Who can help in this matter, please advise the solution.

Upvotes: 0

Views: 82

Answers (2)

Pax Beach
Pax Beach

Reputation: 2793

This solution helps me:

Android SDK 21 has the method finishAndRemoveTask, it solves the issue.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
    finishAndRemoveTask();
} else
{
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        finishAffinity();
    } else
    {
        finish();
    }
}
Process.killProcess(Process.myPid());

Upvotes: 0

josemgu91
josemgu91

Reputation: 719

When you remove an entry from the recent applications list, you are removing a task related to an app process (which can contain multiple activities). You can do this by software BUT you'll need two permissions which can only be used if your app has system level privileges (which isn't your case, because only firmware level apps can have that with a special signature key). Check out this response.

Upvotes: 1

Related Questions