Wifi Application

Discussion in 'Application Development' started by chandradeor, Jul 14, 2013.

  1. chandradeor

    chandradeor Member
    5

    Jul 5, 2013
    5
    0
    5
    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
    26

    Jul 15, 2013
    30
    8
    26
    Ph.D. Candidate
    Michigan
    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

Loading...