Android Network connection notification triggered frequently?
<p>I have used the following code to get the network connection state.</p>

<pre><code>ConnectivityManager _connec = (ConnectivityManager) context.getSystemService   (Context.CONNECTIVITY_SERVICE);

if (_connec != null &amp;&amp; (_connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED)
          || (_connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED)) {
   Log.d("nw",
"Device is connected to the network. ");
}
</code></pre>

<p>I got the network connect / disconnect state. But it trggered frequently two or three time for the single change. If I enable WIFI this connection check is triggered two or more times continuously.. How to get the single notification for the single change event.. </p>

<p>Note: It happen on few devices only (LG,Sony Xperia)</p>
