1

I am listening for "android.net.conn.CONNECTIVITY_CHANGE" in my app with a broadcast receiver. It does work, but the only problem I have is that there is a huge delay in receiving this broadcast. It takes between 1-2 seconds for the app to receive this broadcast. Am I doing something wrong? My Manifest entry -

<receiver android:name=".ConnectivityBroadcastReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
            </intent-filter>
</receiver>

and ConnectivityBroadcastReceiver class -

public class ConnectivityBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e(TAG,"Broadcast received");
        final String action = intent.getAction();
        if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
            ConnectivityUtil.checkConnectivity(context);
        }
    }
}
Sourabh86
  • 744
  • 10
  • 18
  • 1
    Check out the solution here: http://stackoverflow.com/questions/25305698/android-network-state-change-detection-takes-time – liminal Jun 03 '16 at 14:11
  • @liminal thanks! I somehow missed this while Googling and searching on SO. Still, no one knows why this happens? – Sourabh86 Jun 03 '16 at 17:36
  • not sure :(. is there way to upgrade my comment to an accepted answer? i am relatively new to stackoverflow – liminal Jun 03 '16 at 17:41

0 Answers0