1. Hot New Devices! HTC One M9 | Samsung Galaxy S6 | LG G4

Wifi Application


  1. chandradeor

    chandradeor Member

    Hi frnds i am new to android application development. I have a doubt abt the wifi based android application.

    Do we need to explicitly use Wifimanager in our source code for developing apps which will receive wifi data or the OS will Take care of wifi things.

    plz clarifi

    Advertisement
  2. Armuro

    Armuro Active Member

    Use a broadcast receiver to listen to if NETWORK_STATE_CHANGED_ACTION event.

    Then in your receiver:

    public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub

    ConnectivityManager conMngr = (ConnectivityManager)context.getSystemService(context.CONNECTIVITY_SERVICE);
    android.net.NetworkInfo wifi = conMngr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    android.net.NetworkInfo mobile = conMngr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

    if (wifi.isConnected()){

    Log.d(LOG_TAG, "connected to wifi");

    //receive data


    }

    }

Share This Page