All Projects → JobGetabu → DroidNet

JobGetabu / DroidNet

Licence: other
DroidNet is an Android Networking Library listening for network connection state and Internet connectivity with the assumption that active internet connection or not. Connecting to a network doesn’t necessarily mean that device has active internet connection

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to DroidNet

Connectivity
🌐 Makes Internet connectivity detection more robust by detecting Wi-Fi networks without Internet access.
Stars: ✭ 1,476 (+2242.86%)
Mutual labels:  internet-connectivity
cross connectivity
A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Android, Web, Windows, Linux and macOS.
Stars: ✭ 27 (-57.14%)
Mutual labels:  internet-connectivity
connection checker
Android library for checking the internet connectivity of a device.
Stars: ✭ 26 (-58.73%)
Mutual labels:  internet-connectivity
ots
A widget that can show loaders, notifications, internet connectivity changes as Overlay.
Stars: ✭ 20 (-68.25%)
Mutual labels:  internet-connectivity

DroidNet

FOSSA Status Hex.pm DroidNet is an Android Networking Library listening for network connection state and Internet connectivity with assumption that active internet connection or not. Connecting to a network doesn’t necessarily mean that device has active internet connection

Spread Some ❤️

GitHub followers Twitter Follow

Getting Started

These instructions will help you set up this library easily on your current project and working in no time. You only need a few configurations to start working!

Installing

To be able to use the following library, you will need to add the following gradle dependency in your

build.gradle Project level

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

build.gradle module

implementation 'com.github.JobGetabu:DroidNet:v2.0.0'

That is the basic set up needed to be able to use the library in your applications!

Permissions

First, we need to add these permission to our Android Manifest file :

<uses-permission android:name="android.permission.INTERNET" />

That's it, you have set up the required permissions and ready to go!

Usage

In your Main Application

import com.droidnet.old.DroidNet;
...


public class MyApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        DroidNet.init(this);
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        DroidNet.getInstance().removeAllInternetConnectivityChangeListeners();
    }
}

In your Activity

import com.droidnet.old.DroidListener;
import com.droidnet.old.DroidNet;
...


public class MainActivity extends AppCompatActivity implements DroidListener {

    //...

    private DroidNet mDroidNet;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //...
        mDroidNet = DroidNet.getInstance();
        mDroidNet.addInternetConnectivityListener(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mDroidNet.removeInternetConnectivityChangeListener(this);
    }

    @Override
    public void onInternetConnectivityChanged(boolean isConnected) {
      
        if (isConnected) {
            //do Stuff with internet
            netIsOn();
        } else {
            //no internet
            netIsOff();
        }
    }

    private void netIsOn(){...}

    private void netIsOff(){...}
}

Take a look at this sample project which has a sample implementation of the library.

Contributing and Issues

Please feel free to contribute or open issues, if any and I will be happy to help out!

Proguard

You are all set.

Stargazers over time

Stargazers over time

TODO

  • add kotlin support
  • use lifecycle aware components
  • livedata
  • android Q and latest permissions
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].