Nougat changed the way it handles CONNECTIVITY_CHANGED intents (basically ignoring it, forcing devs to use the job scheduler) so this leaves me wondering:
If I have
public class ConnectivityReceiver
{
public static boolean getWifiStatus(Context context)
{
// To get System Connectivity status
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
if (null != activeNetwork)
{
// Check For Wifi Status
if(activeNetwork.getType() == ConnectivityManager.TYPE_WIFI)
return true;
else
return false;
}
return false;
}
public class NetworkMgr extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ConnectivityReceiver cf = new ConnectivityReceiver();
boolean status = cf.getWifiStatus(context);
if(status)
{
Toast.makeText(context,"Wifi Connection is On.", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(context,"Wifi Connection is Off.", Toast.LENGTH_SHORT).show();
}
}
}