Added fail-safe

This commit is contained in:
M66B 2021-02-02 21:05:17 +01:00
parent 389aa04864
commit 36c44fa285
1 changed files with 11 additions and 4 deletions

View File

@ -767,11 +767,18 @@ public class Helper {
}
static void excludeFromRecents(Context context) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) {
try {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
if (am == null)
return;
List<ActivityManager.AppTask> tasks = am.getAppTasks();
if (tasks != null && tasks.size() > 0)
tasks.get(0).setExcludeFromRecents(true);
if (tasks == null || tasks.size() == 0)
return;
tasks.get(0).setExcludeFromRecents(true);
} catch (Throwable ex) {
Log.e(ex);
}
}