🅽🅴🆃🆆🅾🆁🅺🆇 An easy & handy library to monitor device internet connection status.
NetworkXLifecycle.Activity
or NetworkXLifecycle.Application
).SmartConfig
to replace old config [NetworkXConfig
has been deprecated].NetworkX
, enabled smart refactoring to replace old API with new one.NoInternetDialogV2.forceClose()
] added to close Dialog
forcefully.NoInternetDialogV2
.JetPack Compose
version.Add the JitPack repository to your build file .
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Add the dependency.
dependencies {
implementation 'com.github.rommansabbir:NetworkX:4.2.0'
}
Initialize NetworkX
from your Application.onCreate()
//Deprecated way
val builder = NetworkXConfig.Builder()
.withApplication(this)
// You can disable speed meter if not required
.withEnableSpeedMeter(true)
.build()
NetworkXProvider.enable(builder)
//New smart way
NetworkXProvider.enable(SmartConfig(this, true, NetworkXLifecycle.Application))
isInternetConnected
or isInternetConnectedLiveData
or isInternetConnectedFlow
. isInternetConnectedFlow.collectLatest {
lifecycleScope.launch {
textView.text = "Internet connection status: $it"
}
}
LastKnownSpeed
] call extension variablelastKnownSpeed
or lastKnownSpeedLiveData
or lastKnownSpeedFlow
lastKnownSpeed?.let {
textView2.text ="S-${it.speed}|T-${it.networkTypeNetwork}|SS-${it.simplifiedSpeed}"
}
NoInternetDialogV2(
activity = WeakReference(this@MainActivity),
title = "No Internet Bro",
message = "This is just a dummy message",
buttonTitle = "Okay",
isCancelable = true
) { /* Button Presses */ }
NoInternetDialogV2.forceClose()
NoInternetDialogV2
is currently visible or not. NoInternetDialogV2.isVisible
val ui = defaultNoInternetUI()
NoInternetDialogCompose(
true,
ui,
{ /*Dialog Cancelled*/ },
{ /*Dialog closed by user, by pressing action button*/ }
)
MutableStateFlow
) Last Known Speed or Internet Connection Status,required CoroutineScope
works under a Dispatchers.IO
context.false
.NONE
.✔ Website
Copyright (C) 2022 Romman Sabbir
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.