Catch possible exceptions when the receiver is already unregistered

This commit is contained in:
残页 2024-03-29 11:40:00 +08:00 committed by John Wu
parent d33b077a13
commit c8fe0f5524

View File

@ -116,7 +116,10 @@ public final class APKInstall {
if (onFailure != null) {
onFailure.run();
}
context.getApplicationContext().unregisterReceiver(this);
try {
context.getApplicationContext().unregisterReceiver(this);
} catch (IllegalArgumentException ignored) {
}
}
}
latch.countDown();
@ -126,7 +129,10 @@ public final class APKInstall {
private void onSuccess(Context context) {
if (onSuccess != null)
onSuccess.run();
context.getApplicationContext().unregisterReceiver(this);
try {
context.getApplicationContext().unregisterReceiver(this);
} catch (IllegalArgumentException ignored) {
}
}
@Override