Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadisa committed Aug 2, 2020
1 parent 52b2876 commit 83b7dd0
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.content.Intent
import android.content.IntentFilter
import android.net.*
import android.os.Build
import android.util.Log
import androidx.lifecycle.LiveData

/*
Expand Down Expand Up @@ -49,10 +50,14 @@ class Lifemark constructor(private val context: Context) {

override fun onInactive() {
super.onInactive()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
connectivityManager.unregisterNetworkCallback(connectivityManagerCallback())
else
context.unregisterReceiver(networkReceiver)
try{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
connectivityManager.unregisterNetworkCallback(connectivityManagerCallback())
else
context.unregisterReceiver(networkReceiver)
}catch (e: Exception) {
Log.e("Lifemark", "NetworkCallback already unregistered")
}
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
Expand Down

0 comments on commit 83b7dd0

Please sign in to comment.