Do not print a trace when calling the private finish() overload fails

pull/1027/head
Alexander Bakker 2 years ago
parent 715c5112ab
commit 9f55d4f659

@ -74,15 +74,20 @@ public abstract class AegisActivity extends AppCompatActivity implements VaultMa
}
@SuppressLint("SoonBlockedPrivateApi")
@SuppressWarnings("JavaReflectionMemberAccess")
@Override
public void onLocked(boolean userInitiated) {
setResult(RESULT_CANCELED, null);
try {
// Call a private overload of the finish() method to prevent the app
// from disappearing from the recent apps menu
Method method = Activity.class.getDeclaredMethod("finish", int.class);
method.setAccessible(true);
method.invoke(this, 2); // FINISH_TASK_WITH_ACTIVITY = 2
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
// On recent Android versions, the overload of the finish() method
// used above is no longer accessible
finishAndRemoveTask();
}
}

Loading…
Cancel
Save