diff options
author | pacien | 2018-09-27 17:28:54 +0200 |
---|---|---|
committer | pacien | 2018-09-27 17:28:54 +0200 |
commit | 31c49c198e2ddc56565b04675fc167df237de0d3 (patch) | |
tree | f71259ea35707ed78c01799eace08b83ce9208fb /app/src/main | |
parent | ec3bc745918b588072b5104e571a929e17df5732 (diff) | |
download | tincapp-31c49c198e2ddc56565b04675fc167df237de0d3.tar.gz |
Handle unregistered receiver de-registration
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/service/ConnectivityChangeReceiver.kt | 7 |
1 files changed, 6 insertions, 1 deletions
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 | |||
25 | import android.net.ConnectivityManager | 25 | import android.net.ConnectivityManager |
26 | import org.pacien.tincapp.commands.Tinc | 26 | import org.pacien.tincapp.commands.Tinc |
27 | import org.slf4j.LoggerFactory | 27 | import org.slf4j.LoggerFactory |
28 | import java.lang.IllegalArgumentException | ||
28 | 29 | ||
29 | /** | 30 | /** |
30 | * @author pacien | 31 | * @author pacien |
@@ -55,6 +56,10 @@ object ConnectivityChangeReceiver : BroadcastReceiver() { | |||
55 | } | 56 | } |
56 | 57 | ||
57 | fun unregisterWatcher(context: Context) { | 58 | fun unregisterWatcher(context: Context) { |
58 | context.unregisterReceiver(this) | 59 | try { |
60 | context.unregisterReceiver(this) | ||
61 | } catch (e: IllegalArgumentException) { | ||
62 | // already unregistered | ||
63 | } | ||
59 | } | 64 | } |
60 | } | 65 | } |