All Projects → perusudroid → NetworkPro

perusudroid / NetworkPro

Licence: other
Simple library to handle network connections in different views in just few lines of code.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to NetworkPro

AndroidBatteryStats
Displays all battery stats of an Android device using broadcast receiver.
Stars: ✭ 20 (+0%)
Mutual labels:  broadcast-reciever
android-live-broadcasts
Live broadcast receiver library for Android
Stars: ✭ 19 (-5%)
Mutual labels:  broadcast-reciever
LockerScreen
Android lock screen,slide to unlock ! 安卓锁屏,上滑解锁,效果酷炫,值得拥有!
Stars: ✭ 81 (+305%)
Mutual labels:  broadcast-reciever
CEventCenter
一个Android事件分发中心库,基于对象池及接口回调实现。实现类似BroadcastReceiver/RxBus/EventBus等的消息事件传递功能,用于在Activity/Fragment/Service之间的消息传递通讯。
Stars: ✭ 116 (+480%)
Mutual labels:  broadcast-reciever
k8s-netchecker-server
Basic network checker service to check DNS and connectivity in kubernetes cluster
Stars: ✭ 58 (+190%)
Mutual labels:  network-checker
My Android Garage
A quick reference guide for Android development.
Stars: ✭ 66 (+230%)
Mutual labels:  broadcast-reciever

NetworkPro

Simple library to handle network connections in different views in just few lines of code. Primary goal of this library is to simplify the overall process in few lines of code. More options and customization available in code.

Watch the video

Usage

First and foremost in AndroidManifest file register broadcast receiver

<receiver
         android:name="com.perusudroid.networkchecker.broadcast.NetworkManager"
         android:enabled="true"
         android:exported="true">
         <intent-filter>
             <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
             <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
         </intent-filter>
     </receiver>

Make sure to use permission

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

To handle network connections within activity

new NetworkManager.Builder()
                      .callback(this) // INetworkListener methods will be trigged on network connection/disconnection
                      .build();

To show toast message

         new NetworkManager.Builder()
             .showMessage()  // show default toast message to user
              .build();

To show toast with custom message

new NetworkManager.Builder()
           .showCustomMessage(getString(R.string.tst_network_connected), getString(R.string.tst_netword_disconnected)) 
           .build();

To show snackbar

         new NetworkManager.Builder()
              .showSnack(this) // show default snackbar message
              .build();

To show snackbar with custom message

          new NetworkManager.Builder()
           .showCustomSnack(this, getString(R.string.snk_network_connected), getString(R.string.snk_netword_disconnected), Color.WHITE, Color.BLACK, Color.RED, Color.GREEN) 
            .build();

To show alert dialog

        new NetworkManager.Builder()
            .showAlert(this, this) // show default alert message
             .build();

To show alert dialog with custom message and actions

         new NetworkManager.Builder()
           .showCustomAlert(this, "Network has been disconnected", this) // show custom alert
           .build();

To load activity with default message and action

      new NetworkManager.Builder()
            .loadPage() // load activity
            .build();

To load activity with custom message and action

          new NetworkManager.Builder()
             .loadCustomPage(Constants.networkMsg.DISCONNECTED_PAGE, false, true) //load activity with custom message
            .build();

Download

Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency

dependencies {
        implementation 'com.github.Periyanayagam:NetworkPro:1.1'
}

Kindly check in your device and if any issues, post in issue section. Will be fixed and updated.

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].