Skip to content

🌐 Light library to check internet connection in android apps easily

License

Notifications You must be signed in to change notification settings

raheemadamboev/check-internet-android

Repository files navigation

Check Internet

Android Version License API

🌐 Light library to check internet connection in android apps easily. It checks real internet connection by connecting to Google's DNS server. If call is successful then internet is working else not working.

Setup

Add it in your root build.gradle at the end of repositories:

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

Include below dependency in build.gradle of application and sync it:

implementation 'com.github.raheemadamboev:check-internet-android:1.1.1'

Implementation

Check internet connection (callback API):

CheckInternet().check { connected ->
  if (connected) { 
      // there is internet                
  } else { 
      // there is no internet                  
  }
}

Check internet connection (suspend API):

viewModelScope.launch {
  val connected = CheckInternet().check()
  if (connected) { 
      // there is internet                
  } else { 
      // there is no internet                  
  }
}

Demo

Checked internet connection via wifi and mobile network. Download demo

Italian Trulli

Projects using this library

GoTest 150 000+ downloads in Google Play Store

Buxgalteriya schyotlar rejasi 20 000+ downloads in Google Play Store

Irregular Verbs 20 000+ downloads in Google Play Store

License

Designed and developed by raheemadamboev (Raheem) 2022.

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.