question

Sukhbir Singh avatar image
Sukhbir Singh asked Jeffrey Blattman answered

Remove application from recent list in clover mini first generation device

Hi,


I am using the following code to remove the application from the recent apps list:

if (android.os.Build.VERSION.SDK_INT >= 21) {
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) {
am.clearApplicationUserData();
am.killBackgroundProcesses(getPackageName());
List<ActivityManager.AppTask> tasks = am.getAppTasks();
if (tasks != null && tasks.size() > ZERO) {
for (ActivityManager.AppTask appTask : tasks) {
appTask.finishAndRemoveTask();
}
}
}
finishAndRemoveTask();
}


Code is working as aspected with Clover mini second generation because the clover mini second generation has the android version > 21.

But in the clover mini first generation, we are unable to remove the application from recent list.

Can you please suggest a way to remove the application from the recent list which is also supported by Clover mini first-generation device?


Thanks.

Clover Android SDKClover MiniClover Flex
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered

Could you explain why you want to do this?

If you are are trying to unconditionally keep your activities from appearing in recents you can use:

https://developer.android.com/guide/topics/manifest/activity-element#exclude

I am not aware of a method to conditionally remove an app from recents. If you find yourself killing processes in Android it usually indicates a design issue.

Another idea is to let it be brought in from recents, but just make sure that it knows what state it should be in (including knowing if the state is invalid).

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community