Code example for ConnectivityManager

Methods: getNetworkInfo

0
         * @return Returns true if WiFi is on, false otherwise. 
         */ 
        public boolean getWiFiIsOn() { 
            ConnectivityManager connManager = (ConnectivityManager)mContext.getSystemService(
                    Context.CONNECTIVITY_SERVICE);
            NetworkInfo info = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
            Log.i(LOG_TAG, "WiFi Connection state is currently: " + info.isConnected());
            return info.isConnected();
        } 
    } 
 
    /** 
     * {@inheritDoc} 
     */ 
    @Override 
    public void setUp() throws Exception { 
        mContext = getInstrumentation().getContext();
        mDownloadManager = (DownloadManager)mContext.getSystemService(Context.DOWNLOAD_SERVICE);
        mReceiver = registerNewMultipleDownloadsReceiver();
    }