1

I would like to implement a listener to change the state of WiFi and mobile Internet

created a simple BroadcastReceiver c intent filter android.net.conn.CONNECTIVITY_CHANGE

it works, but I've noticed that when you turn on/off my WiFi BroadcastReceiver receives two identical intent with a delay of about 100 milliseconds.

Why and how can I fix it?

BradleyIW
  • 1,338
  • 2
  • 20
  • 37
Makc Balashov
  • 21
  • 1
  • 5

1 Answers1

2

please add this Intent Filter too..

<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />

this will notify you about the Wifi State (ON or OFF)

Itzik Samara
  • 2,278
  • 1
  • 14
  • 18
  • the boradcastReceiver can catch a lot of Intent Filters just check the data is returning.. – Itzik Samara Aug 09 '15 at 16:39
  • I was looking at the same data – Makc Balashov Aug 09 '15 at 16:54
  • Intent: Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x8000010 cmp=xxxxx/.APIv1.connection.NetworkStateReceiver (has extras) } Conectivity: true networkInfo: NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: false InetCondition: 0 – Makc Balashov Aug 09 '15 at 17:00
  • please check this example : http://stackoverflow.com/questions/10733121/broadcastreceiver-when-wifi-or-3g-network-state-changed – Itzik Samara Aug 09 '15 at 17:04