Hi Thierry,

Implement a broadcast receiver which listens for the event

android.net.wifi.supplicant.CONNECTION_CHANGE.

This is from the API description

     * Broadcast intent action indicating that a connection to the
supplicant has
     * been established (and it is now possible
     * to perform Wi-Fi operations) or the connection to the
supplicant has been
     * lost. One extra provides the connection state as a boolean,
where {...@code true}
     * means CONNECTED.

You will find all supported intents in the following file

frameworks/base/wifi/java/android/net/wifi/WifiManager.java

Of course also more information on the  Android API pages

http://developer.android.com/reference/android/net/wifi/WifiManager.html#SUPPLICANT_CONNECTION_CHANGE_ACTION


The following code is from frameworks/base/services/java/com/android/
server/WifiWatchdogService.java.

    /**
     * Registers to receive the necessary Wi-Fi broadcasts.
     */
    private void registerForWifiBroadcasts() {
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction
(WifiManager.NETWORK_STATE_CHANGED_ACTION);
        intentFilter.addAction
(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
        intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
        mContext.registerReceiver(mReceiver, intentFilter);
    }

....


        @Override
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();
            if (action.equals
(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
                handleNetworkStateChanged(
                        (NetworkInfo) intent.getParcelableExtra
(WifiManager.EXTRA_NETWORK_INFO));
            } else if (action.equals
(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) {
                handleSupplicantConnectionChanged(
                        intent.getBooleanExtra
(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false));
            } else if (action.equals
(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
                handleWifiStateChanged(intent.getIntExtra
(WifiManager.EXTRA_WIFI_STATE,
                        WifiManager.WIFI_STATE_UNKNOWN));
            }
        }


Let me know, if this was helpful.

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.





On Jun 19, 4:29 am, GAYET Thierry <[email protected]> wrote:
> Hi,
>
> For one of my application, i need to be notifiate when the wifi have been 
> linked with an Access Point and got its network config. In other words when 
> the wireless network interface can be used.
>
> Is there an easy way to do it quickly ?
>
>  Regards.
>
> Thierry GAYET
> NextInnovation.org
> +33(0)663.849.589
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting
-~----------~----~----~----~------~----~------~--~---

Reply via email to