I have registered ConnectivityManager.CONNECTIVITY_ACTION
to get broadcast when WIFI is connected
. It doesn't work when my mobile data is enabled
and connected WIFI has no internet connection.
I have created a hotspot
in another mobile device which has no internet connection. In my device (Android 6.1)
mobile data
is enabled. When I try to connect to the hotspot
, broadcast doesn't trigger. It works every time when mobile data is disable
.
IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(networkStateReceiver, intentFilter);
private BroadcastReceiver networkStateReceiver = new BroadcastReceiver()
{
public void onReceive(Context context, Intent intentData)
{
String action = intentData.getAction();
Log.e("action",action);
if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)){
// trigger once (when register).
}
}
}