InternetAvailabilityChecker
this project checks if internet is present or not on device. Connecting to network doesn't mean internet access so this project pings google to check if internet is present or not
Install / Use
/learn @AggarwalAnkit/InternetAvailabilityCheckerREADME
InternetAvailabilityChecker
this project checks if active internet is present or not on device. Connecting to network doesn't mean internet access so this project pings google to check if internet is present or not
How To Use
To use the library follow the following steps:
- Add the dependency as follows:
implementation 'com.treebo:internetavailabilitychecker:1.0.4' - Initialise it in application’s
onCreate()function. This is necessary step before starting using the library because it needs context to register connectivity broadcast receiver. It stores only weakreference to the context, so no need to worry about memory leaks. Also it does lazy registration of receiver; i.e. it registers receiver whenever first listener attaches to listen to internet changes and unregister itself when last listener stops listening.InternetAvailabilityChecker.init(this); - Implement InternetConnectivityListener interface where ever you want to listen to internet connectivity changes (E.g. in activity, fragment or service).
public class MainActivity extends AppCompatActivity implements InternetConnectivityListener { @Override public void onInternetConnectivityChanged(boolean isConnected) { //do something based on connectivity } } - Get instance of InternetAvailabilityChecker and Add listener whenever you want to start listening to connectivity changes (e.g. in activity’s
onCreate()function). It keeps a weakreference to the subscriber and clears the references whenever subscriber gets destroyed (when there is no more strong reference referencing it).mInternetAvailabilityChecker = InternetAvailabilityChecker.getInstance(); mInternetAvailabilityChecker.addInternetConnectivityListener(this); - Remove listener whenever you are done (e.g. in activity’s
onDestroy(), fragment’sonDetach()or service’sonDestroy()).mInternetAvailabilityChecker.removeInternetConnectivityChangeListener(this);
Medium Link
Related Skills
node-connect
339.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.8kCommit, push, and open a PR
