From 31c49c198e2ddc56565b04675fc167df237de0d3 Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 27 Sep 2018 17:28:54 +0200 Subject: Handle unregistered receiver de-registration --- .../java/org/pacien/tincapp/service/ConnectivityChangeReceiver.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/pacien/tincapp/service/ConnectivityChangeReceiver.kt b/app/src/main/java/org/pacien/tincapp/service/ConnectivityChangeReceiver.kt index ba9aa95..a72a1aa 100644 --- a/app/src/main/java/org/pacien/tincapp/service/ConnectivityChangeReceiver.kt +++ b/app/src/main/java/org/pacien/tincapp/service/ConnectivityChangeReceiver.kt @@ -25,6 +25,7 @@ import android.content.IntentFilter import android.net.ConnectivityManager import org.pacien.tincapp.commands.Tinc import org.slf4j.LoggerFactory +import java.lang.IllegalArgumentException /** * @author pacien @@ -55,6 +56,10 @@ object ConnectivityChangeReceiver : BroadcastReceiver() { } fun unregisterWatcher(context: Context) { - context.unregisterReceiver(this) + try { + context.unregisterReceiver(this) + } catch (e: IllegalArgumentException) { + // already unregistered + } } } -- cgit v1.2.3