Hello, I have a BroadcastReceiver that returns me
Log.i("Network", "Network connected : " + ni.getTypeName()); WIFI o MOBILE
and another method that returns me in case of being WIFI its
Log.i("Network", "Name " + ssid);
there is a method that must be executed if it ni.getTypeName()
is WIFI
and suddenly changes to MOBILE
and vice versa and if it is in WIFI
and the SSID
changes also execute this method.
If I understand your question correctly, this may help you.
https://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html?hl=en
You can use these 2 methods to detect network type:
To determine the change, you can define two constants to define the two network types:
and another determine the current type active and the last network detected:
The BroadCastReceiver should constantly check the type:
At the end you simply compare the value of the last active network.
You store the value of the "last active network":