// Code is in Kotlin here
// variable which subscribe and unsubscribe
private var sendStateSubscription: Subscription? = null
verride fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
sendStateSubscription= RxNetwork.connectivityChanges(requireContext(), cm).subscribe(Action1 {
if(it)
//conected
else
//disconnected
})
}
override fun onDestroy() {
sendStateSubscription?.unsubscribe()
sendStateSubscription = null
super.onDestroy()
}
// Code is in Kotlin here
// variable which subscribe and unsubscribe
private var sendStateSubscription: Subscription? = null
verride fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
sendStateSubscription= RxNetwork.connectivityChanges(requireContext(), cm).subscribe(Action1 {
if(it)
//conected
else
//disconnected
})
}
override fun onDestroy() {
sendStateSubscription?.unsubscribe()
sendStateSubscription = null
super.onDestroy()
}