I have registered a broadcastreceiver in my manifest. It is registered for
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
I also have registered the following permissions:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
It fires when I disable/enable wifi and when my wifi is disconnected after losing the signal (when I go away from the hotspot). But there is no broadcast when I came back to my hotspot (when wifi is connected again). I have testet it with Samsung Galaxy S5 (Android 6.0.1). Is there a peculiarity I don't know?
The code for my broadcastReceiver
public class StatusReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
if(intent.getAction() != null)
Log.d("action", intent.getAction());
}
}
<receiver android:name=".receivers.StatusReceiver">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
There is android.net.conn.CONNECTIVITY_CHANGE
when I leave the network.
And android.net.wifi.WIFI_STATE_CHANGED
when I toggle the wifi button.
But no broadcast when I am returning to the hotspot or when my wifi is connected after enabling wifi