A lightweight Android utility library to check internet connectivity, type of connection, and whether the device is using Wi-Fi or mobile data.
- Detects if the device is connected to the internet
- Identifies connection type: Wi-Fi or Mobile Data
- Checks if the connection is validated
- Simple static methods, no setup required
Groovy (settings.gradle)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}Kotlin DSL (settings.gradle.kts)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}Replace Tag with the latest release tag (e.g., v1.0.1).
Groovy (app/build.gradle)
dependencies {
implementation 'com.github.aakashsakhalkar:InternetChecker:v1.0.1'
}Kotlin DSL (build.gradle.kts)
dependencies {
implementation("com.github.aakashsakhalkar:InternetChecker:v1.0.1")
}Maven
<dependency>
<groupId>com.github.aakashsakhalkar</groupId>
<artifactId>InternetChecker</artifactId>
<version>v1.0.1</version>
</dependency>Import the class:
import com.aakash.netstatus.NetStatus;Example:
if (NetStatus.isConnectedToInternet(context)) {
String type = NetStatus.getConnectionType(context);
Log.d("Network", "Connected via " + type);
} else {
Log.d("Network", "No internet connection");
}| Method | Description |
|---|---|
isConnectedToInternet(ctx) |
Returns true if device has validated internet access |
hasWiFi(ctx) |
Returns true if device is currently using Wi-Fi |
hasMobileData(ctx) |
Returns true if device is using mobile data |
getConnectionType(ctx) |
Returns "WIFI", "MOBILE", or "NONE" |
All methods are static and can be used directly without initialization.
- Minimum SDK: 21 (Android 5.0 Lollipop)
- No additional dependencies
MIT License