DEV Community

Cover image for ConnectivityLifeData for API 30 & lower APIs
Mbuodile Obiosio
Mbuodile Obiosio

Posted on • Updated on

ConnectivityLifeData for API 30 & lower APIs

I made this super lightweight library to enable Android Developers handle network changes across API 16 to 30.

GitHub logo mbobiosio / ConnectivityLiveData

A super simple, super light-weight lifecycle aware solution written in Kotlin that helps you to capture network connectivity events with support for lower APIs

Codacy Badge Maintainability Rating Platform API


A super simple, super light-weight lifecycle aware solution written in Kotlin that helps you to capture network connectivity events with support for lower APIs

USAGE

Including in your project

Add below codes to your root build.gradle

allprojects {
   repositories {
      maven { url 'https://jitpack.io' }
   }
}

Add lifecycleconnectivity dependency to your project's module build.gradle

implementation 'com.github.mbobiosio:lifecycleconnectivity:1.0.2'
Enter fullscreen mode Exit fullscreen mode
  • Use in your Activity
 val lifecycleService = LifecycleService(this)
 lifecycleService.observe(this, {
     Log.d("Status", "$it")
 })
Enter fullscreen mode Exit fullscreen mode
  • Use in your Fragment
 val lifecycleService = LifecycleService(activity as Activity)
 lifecycleService.observe(viewLifecycleOwner, {
 })
Enter fullscreen mode Exit fullscreen mode

Contribute

If you want to contribute to this app, you're always welcome See Contributing Guidelines.

📝 License

This project is released under the MIT license See LICENSE for details.

MIT License

Copyright (c) 2020 Mbuodile Obiosio

Permission is hereby granted, free of charge, to any person obtaining a copy

Feel to create a pull request.

Discussion (0)