NoNet is an Android library for monitoring network connectivity.
Monitor for network connectivity changes and show a snackbar when disconnected:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
NoNet.monitor(this)
.poll()
.snackbar()
.start();
}
@Override
protected void onDestroy() {
super.onDestroy();
NoNet.stopMonitoring();
}
Set the global configuration:
NoNet.configure()
.endpoint("https://google.com")
.timeout(5)
.pollFrequency(60);
Make a one-off network connectivity check with a custom configuration, showing a toast if disconnected, and provide a callback to be invoked on result:
NoNet.check(this)
.configure(configuration)
.toast()
.callback(new Monitor.Callback() {
@Override
public void onConnectionChanged(int connectionStatus) {
// TODO
}
})
.start();
Download the latest AAR or grab via Gradle:
compile 'com.keiferstone:nonet:1.0.6'
or Maven:
<dependency>
<groupId>com.keiferstone</groupId>
<artifactId>nonet</artifactId>
<version>1.0.6</version>
</dependency>
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.