https://github.com/pharosproduction/inet-monitor
Library to display and monitor connection status. This library is described in the following article. https://medium.com/pharos-production/check-for-internet-connection-in-the-android-application-part-2-ef45f1f29b8 . https://pharosproduction.com
https://github.com/pharosproduction/inet-monitor
Last synced: 5 months ago
JSON representation
Library to display and monitor connection status. This library is described in the following article. https://medium.com/pharos-production/check-for-internet-connection-in-the-android-application-part-2-ef45f1f29b8 . https://pharosproduction.com
- Host: GitHub
- URL: https://github.com/pharosproduction/inet-monitor
- Owner: PharosProduction
- Created: 2019-01-31T12:29:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-12-08T17:09:17.000Z (6 months ago)
- Last Synced: 2024-12-08T18:19:24.483Z (6 months ago)
- Language: Kotlin
- Homepage: https://pharosproduction.com
- Size: 141 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
By [Dmytro Nasyrov, Founder, CTO at Pharos Production Inc.](https://www.linkedin.com/in/dmytronasyrov/)
And [Pharos Production Inc. - Web3, blockchain, fintech, defi software development services](https://pharosproduction.com)# inet-monitor
Library to display and monitor connection statusLibrary usage
1. Add maven repository to your gradle:
```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
2. In your build.gradle add :
```
implementation 'com.github.PharosProduction:inet-monitor:1.0.0'
```
3. Register InetMonitor```
class App : Application() {// Variables
lateinit var monitor: InetMonitor
// Life
override fun onCreate() {
super.onCreate()
monitor = InetMonitor(this)
monitor.registerReceiver()
}
}
```4. In your Activity:
```
class MainActivity : AppCompatActivity(), InetMonitor.ConnectionListener {
// Lifeoverride fun listenConnection(isConnected: Boolean) {
if (!isConnected) {
InetMonitor.showNotification(this)
} else InetMonitor.hideNotification(this)}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)(application as App).monitor.addConnectionListener(this)
}
}
```