In my application, I have a BroadcastReceiver that runs as a component via the <receiver> , filtering android.net.conn.CONNECTIVITY_CHANGE intentions.
My goal is simply to know when the Wi-Fi connection was established, so what I do in onReceive() :
NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if(networkInfo.getType() == ConnectivityManager.TYPE_WIFI && networkInfo.isConnected()) { // Wifi is connected }
It works fine, but I always get two identical intentions for about one second when a Wi-Fi connection is established. I tried to look at any information that I could get from intent, ConnectivityManager and WifiManager , but I can not find anything that distinguishes two intentions.
Having looked at the magazine, there is at least one more BroadcastReceiver , which also receives two identical intentions.
It works on HTC Desire with Android 2.2
Any idea why I seem to get a “duplicate” intent when Wifi connects or what's the difference between the two?
android android-broadcastreceiver android-wifi
Torsten Römer Mar 11 '11 at 17:11 2011-03-11 17:11
source share