0

I am working with Android. I have a service that is getting data from a wifi network. I would like to alert the user if they lose connection to that wifi address. I have been trying to work it out, and I think I have narrowed it down to using a BroadcastReceiver. Here is my implementation so far...

WifiReceiver receiverWifi;

protected void onCreate(Bundle savedInstanceState) {

receiverWifi = new WifiReceiver();
registerReceiver(receiverWifi, new IntentFilter(
            WifiManager.NETWORK_STATE_CHANGED_ACTION));  
}

class WifiReceiver extends BroadcastReceiver {


    public void onReceive(Context context, Intent intent) {

    //Does this get executed when the network changes?
    }
}

Specifically, my question is, how can I edit my code to run in my service that will let the user know through a notification that the wifi they were connected to was lost or was changed? Thank you for any help.

mtorres
  • 197
  • 2
  • 14

0 Answers0