Example usage for android.net.wifi WifiManager WIFI_STATE_ENABLED

List of usage examples for android.net.wifi WifiManager WIFI_STATE_ENABLED

Introduction

In this page you can find the example usage for android.net.wifi WifiManager WIFI_STATE_ENABLED.

Prototype

int WIFI_STATE_ENABLED

To view the source code for android.net.wifi WifiManager WIFI_STATE_ENABLED.

Click Source Link

Document

Wi-Fi is enabled.

Usage

From source file:com.android.launcher3.widget.DigitalAppWidgetProvider.java

private void refreshWifiStatus(Context context, RemoteViews widget) {
    mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    int wifiStatus = mWifiManager.getWifiState();
    if (WifiManager.WIFI_STATE_ENABLED == wifiStatus || WifiManager.WIFI_STATE_ENABLING == wifiStatus) {
        widget.setImageViewResource(R.id.wifi, R.drawable.status_wifi_on);
    } else {/* ww  w.jav  a  2 s  .  c  o  m*/
        widget.setImageViewResource(R.id.wifi, R.drawable.status_wifi_off);
    }
}

From source file:org.metawatch.manager.Monitors.java

private static void createWifiReceiver(final Context context) {
    if (wifiReceiver != null)
        return;//w  w w . j ava  2s  .co m
    WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wm.getConnectionInfo();
    if (info != null)
        SignalData.wifiBars = 1 + WifiManager.calculateSignalLevel(info.getRssi(), 4);
    wifiReceiver = new BroadcastReceiver() {
        int wifiBars = 0;

        @Override
        public void onReceive(Context c, Intent intent) {
            String action = intent.getAction();
            if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
                if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
                        WifiManager.WIFI_STATE_UNKNOWN) != WifiManager.WIFI_STATE_ENABLED) {
                    wifiBars = 0;
                }
            } else if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) {
                if (!intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)) {
                    wifiBars = 0;
                }
            } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
                NetworkInfo netInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
                if (netInfo.getState() != NetworkInfo.State.CONNECTED) {
                    wifiBars = 0;
                } else {
                    WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO);
                    if (wifiInfo == null) {
                        wifiBars = 0;
                    } else {
                        wifiBars = 1 + WifiManager.calculateSignalLevel(wifiInfo.getRssi(), 4);
                    }
                }
            } else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) {
                final int newRssi = intent.getIntExtra(WifiManager.EXTRA_NEW_RSSI, -200);
                wifiBars = 1 + WifiManager.calculateSignalLevel(newRssi, 4);
            }
            if (wifiBars != SignalData.wifiBars) {
                SignalData.wifiBars = wifiBars;
                Idle.updateIdle(context, true);
            }
        }
    };
    IntentFilter f = new IntentFilter();
    f.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    f.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
    f.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    f.addAction(WifiManager.RSSI_CHANGED_ACTION);
    context.registerReceiver(wifiReceiver, f);
}

From source file:org.sipdroid.sipua.ui.Receiver.java

@Override
public void onReceive(Context context, Intent intent) {
    String intentAction = intent.getAction();
    if (!Sipdroid.on(context))
        return;/* www .  j  ava2s . c  om*/
    if (!Sipdroid.release)
        Log.i("SipUA:", intentAction);
    if (mContext == null)
        mContext = context;
    if (intentAction.equals(Intent.ACTION_BOOT_COMPLETED)) {
        on_vpn(false);
        engine(context).register();
    } else if (intentAction.equals(ConnectivityManager.CONNECTIVITY_ACTION)
            || intentAction.equals(ACTION_EXTERNAL_APPLICATIONS_AVAILABLE)
            || intentAction.equals(ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE)
            || intentAction.equals(Intent.ACTION_PACKAGE_REPLACED)) {
        engine(context).register();
    } else if (intentAction.equals(ACTION_VPN_CONNECTIVITY) && intent.hasExtra("connection_state")) {
        String state = intent.getSerializableExtra("connection_state").toString();
        if (state != null && on_vpn() != state.equals("CONNECTED")) {
            on_vpn(state.equals("CONNECTED"));
            for (SipProvider sip_provider : engine(context).sip_providers)
                if (sip_provider != null)
                    sip_provider.haltConnections();
            engine(context).register();
        }
    } else if (intentAction.equals(ACTION_DATA_STATE_CHANGED)) {
        engine(context).registerMore();
    } else if (intentAction.equals(ACTION_PHONE_STATE_CHANGED)
            && !intent.getBooleanExtra(context.getString(R.string.app_name), false)) {
        stopRingtone();
        pstn_state = intent.getStringExtra("state");
        pstn_time = SystemClock.elapsedRealtime();
        if (pstn_state.equals("IDLE") && call_state != UserAgent.UA_STATE_IDLE)
            broadcastCallStateChanged(null, null);
        if (!pstn_state.equals("IDLE") && call_state == UserAgent.UA_STATE_INCALL)
            mHandler.sendEmptyMessageDelayed(MSG_HOLD, 5000);
        else if (!pstn_state.equals("IDLE") && (call_state == UserAgent.UA_STATE_INCOMING_CALL
                || call_state == UserAgent.UA_STATE_OUTGOING_CALL))
            mHandler.sendEmptyMessageDelayed(MSG_HANGUP, 5000);
        else if (pstn_state.equals("IDLE")) {
            mHandler.removeMessages(MSG_HOLD);
            mHandler.removeMessages(MSG_HANGUP);
            if (call_state == UserAgent.UA_STATE_HOLD)
                mHandler.sendEmptyMessageDelayed(MSG_HOLD, 1000);
        }
    } else if (intentAction.equals(ACTION_DOCK_EVENT)) {
        docked = intent.getIntExtra(EXTRA_DOCK_STATE, -1) & 7;
        if (call_state == UserAgent.UA_STATE_INCALL)
            engine(mContext).speaker(speakermode());
    } else if (intentAction.equals(ACTION_SCO_AUDIO_STATE_CHANGED)) {
        bluetooth = intent.getIntExtra(EXTRA_SCO_AUDIO_STATE, -1);
        progress();
        RtpStreamSender.changed = true;
    } else if (intentAction.equals(Intent.ACTION_HEADSET_PLUG)) {
        headset = intent.getIntExtra("state", -1);
        if (call_state == UserAgent.UA_STATE_INCALL)
            engine(mContext).speaker(speakermode());
    } else if (intentAction.equals(Intent.ACTION_SCREEN_ON)) {
        if (!PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(
                org.sipdroid.sipua.ui.Settings.PREF_OWNWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_OWNWIFI))
            alarm(0, OwnWifi.class);
    } else if (intentAction.equals(Intent.ACTION_USER_PRESENT)) {
        mHandler.sendEmptyMessageDelayed(MSG_ENABLE, 3000);
    } else if (intentAction.equals(Intent.ACTION_SCREEN_OFF)) {
        if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(
                org.sipdroid.sipua.ui.Settings.PREF_OWNWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_OWNWIFI)) {
            WifiManager wm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
            WifiInfo wi = wm.getConnectionInfo();
            if (wm.getWifiState() != WifiManager.WIFI_STATE_ENABLED || wi == null
                    || wi.getSupplicantState() != SupplicantState.COMPLETED || wi.getIpAddress() == 0)
                alarm(2 * 60, OwnWifi.class);
            else
                alarm(15 * 60, OwnWifi.class);
        }
        if (SipdroidEngine.pwl != null)
            for (PowerManager.WakeLock pwl : SipdroidEngine.pwl)
                if (pwl != null && pwl.isHeld()) {
                    pwl.release();
                    pwl.acquire();
                }
    } else if (intentAction.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
        if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(
                org.sipdroid.sipua.ui.Settings.PREF_SELECTWIFI,
                org.sipdroid.sipua.ui.Settings.DEFAULT_SELECTWIFI))
            mHandler.sendEmptyMessageDelayed(MSG_SCAN, 3000);
    } else if (intentAction.equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
        if (SystemClock.uptimeMillis() > lastscan + 45000
                && PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(
                        org.sipdroid.sipua.ui.Settings.PREF_SELECTWIFI,
                        org.sipdroid.sipua.ui.Settings.DEFAULT_SELECTWIFI)) {
            WifiManager wm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
            WifiInfo wi = wm.getConnectionInfo();
            String activeSSID = null;
            if (wi != null)
                activeSSID = wi.getSSID();
            if (activeSSID != null && (activeSSID.length() == 0 || activeSSID.equals("0x")))
                activeSSID = null;
            List<ScanResult> mScanResults = wm.getScanResults();
            List<WifiConfiguration> configurations = wm.getConfiguredNetworks();
            if (configurations != null) {
                WifiConfiguration bestconfig = null, maxconfig = null, activeconfig = null;
                for (final WifiConfiguration config : configurations) {
                    if (maxconfig == null || config.priority > maxconfig.priority) {
                        maxconfig = config;
                    }
                    if (config.SSID != null
                            && (config.SSID.equals("\"" + activeSSID + "\"") || config.SSID.equals(activeSSID)))
                        activeconfig = config;
                }
                ScanResult bestscan = null, activescan = null;
                if (mScanResults != null)
                    for (final ScanResult scan : mScanResults) {
                        for (final WifiConfiguration config : configurations) {
                            if (config.SSID != null && config.SSID.equals("\"" + scan.SSID + "\"")) {
                                if (bestscan == null || scan.level > bestscan.level) {
                                    bestscan = scan;
                                    bestconfig = config;
                                }
                                if (config == activeconfig)
                                    activescan = scan;
                            }
                        }
                    }
                if (activescan != null)
                    System.out.println("debug wifi asu(active)" + asu(activescan));
                if (bestconfig != null && (activeconfig == null || bestconfig.priority != activeconfig.priority)
                        && asu(bestscan) > asu(activescan) * 1.5 &&
                        /* (activeSSID == null || activescan != null) && */ asu(bestscan) > 22) {
                    if (!Sipdroid.release)
                        Log.i("SipUA:", "changing to " + bestconfig.SSID);
                    if (activeSSID == null || !activeSSID.equals(bestscan.SSID))
                        wm.disconnect();
                    bestconfig.priority = maxconfig.priority + 1;
                    wm.updateNetwork(bestconfig);
                    wm.enableNetwork(bestconfig.networkId, true);
                    wm.saveConfiguration();
                    if (activeSSID == null || !activeSSID.equals(bestscan.SSID))
                        wm.reconnect();
                    lastscan = SystemClock.uptimeMillis();
                } else if (activescan != null && asu(activescan) < 15) {
                    wm.disconnect();
                    wm.disableNetwork(activeconfig.networkId);
                    wm.saveConfiguration();
                }
            }
        }
    }
}

From source file:com.example.sensingapp.SensingApp.java

public void show_screen2() {
    int i;//from  www .ja  va  2  s .c o m
    Location location = null;

    setContentView(R.layout.screen_2_sensors);

    m_chkAccl = (CheckBox) findViewById(R.id.chkAccl);
    m_chkLinearAccl = (CheckBox) findViewById(R.id.chkLinearAccl);
    m_chkGravity = (CheckBox) findViewById(R.id.chkGravity);
    m_chkGyro = (CheckBox) findViewById(R.id.chkGyro);
    m_chkOrient = (CheckBox) findViewById(R.id.chkOrient);
    m_chkMagnet = (CheckBox) findViewById(R.id.chkMagnetic);
    m_chkLight = (CheckBox) findViewById(R.id.chkLight);
    m_chkBarometer = (CheckBox) findViewById(R.id.chkBarometer);

    m_chkMic = (CheckBox) findViewById(R.id.chkMic);
    m_chkCellular = (CheckBox) findViewById(R.id.chkCellular);

    m_chkGPS = (CheckBox) findViewById(R.id.chkGPS);
    m_chkWifi = (CheckBox) findViewById(R.id.chkWifi);

    m_chkAccl.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkLinearAccl.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkGravity.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkGyro.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkOrient.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkMagnet.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkLight.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkBarometer.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkMic.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkCellular.setOnCheckedChangeListener(m_chkSensorEnableListener);

    m_chkGPS.setOnCheckedChangeListener(m_chkSensorEnableListener);
    m_chkWifi.setOnCheckedChangeListener(m_chkSensorEnableListener);

    m_spnScreen2_WiFiScanSpeed = (Spinner) findViewById(R.id.Screen2_spnWiFiScanSpeed);

    m_adpWiFiScanSpeed = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            m_arrsWiFiScanSpeed);
    m_adpWiFiScanSpeed.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    m_spnScreen2_WiFiScanSpeed.setAdapter(m_adpWiFiScanSpeed);
    m_spnScreen2_WiFiScanSpeed.setSelection(m_nWifiScanSpeedIndex);

    m_rdgpSensor = (RadioGroup) findViewById(R.id.RdGpSensor);
    m_rdSensorAccl = (RadioButton) findViewById(R.id.RdSensor_Accl);
    m_rdSensorLinearAccl = (RadioButton) findViewById(R.id.RdSensor_LinearAccl);
    m_rdSensorGravity = (RadioButton) findViewById(R.id.RdSensor_Gravity);
    m_rdSensorGyro = (RadioButton) findViewById(R.id.RdSensor_Gyro);
    m_rdSensorOrient = (RadioButton) findViewById(R.id.RdSensor_Orient);
    m_rdSensorMagnet = (RadioButton) findViewById(R.id.RdSensor_Magnetic);
    m_rdSensorLight = (RadioButton) findViewById(R.id.RdSensor_Light);
    m_rdSensorBarometer = (RadioButton) findViewById(R.id.RdSensor_Barometer);

    m_rdgpSensorMode = (RadioGroup) findViewById(R.id.RdGpSensorMode);
    m_rdSensorModeFastest = (RadioButton) findViewById(R.id.RdSensorMode_Fastest);
    m_rdSensorModeGame = (RadioButton) findViewById(R.id.RdSensorMode_Game);
    m_rdSensorModeNormal = (RadioButton) findViewById(R.id.RdSensorMode_Normal);
    m_rdSensorModeUI = (RadioButton) findViewById(R.id.RdSensorMode_UI);

    m_rdgpSensor.setOnCheckedChangeListener(m_rdgpSensorListener);
    m_rdgpSensorMode.setOnCheckedChangeListener(m_rdgpSensorModeListener);

    configSensorOptionStatus();

    m_mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    if (m_mainWifi.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {
        m_blnWifiSignalEnabled = true;
    } else {
        m_blnWifiSignalEnabled = false;
        m_chkWifi.setEnabled(false);
    }

    this.registerReceiver(m_brcvWifiStateChangedReceiver,
            new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION));

    m_locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    m_blnGPSSignalEnabled = m_locManager.isProviderEnabled(m_sGPSProvider);

    if ((m_locManager != null) && (m_blnGPSSignalEnabled == true)) {
        location = m_locManager.getLastKnownLocation(m_sGPSProvider);
        if (location != null) {
            float fLat = (float) (location.getLatitude());
            float fLng = (float) (location.getLongitude());
            if (location.hasAltitude()) {
                float fAlt = (float) (location.getAltitude());
            }
        }
    }

    m_btnScreen2_Back = (Button) findViewById(R.id.btScreen2_Back);
    m_btnScreen2_Back.setOnClickListener(m_btnScreen2_Back_Listener);
    m_btnScreen2_Next = (Button) findViewById(R.id.btScreen2_Next);
    m_btnScreen2_Next.setOnClickListener(m_btnScreen2_Next_Listener);

    /* No sensor is installed, disable other widgets and show information to user */
    if ((m_blnOrientPresent == false) && (m_blnGyroPresent == false) && (m_blnAcclPresent == false)
            && (m_blnLinearAcclPresent == false) && (m_blnGravityPresent == false)
            && (m_blnMagnetPresent == false) && (m_blnLightPresent == false)
            && (m_blnBarometerPresent == false)) {

        m_rdSensorModeFastest.setEnabled(false);
        m_rdSensorModeGame.setEnabled(false);
        m_rdSensorModeNormal.setEnabled(false);
        m_rdSensorModeUI.setEnabled(false);

    }

    if (m_blnAcclEnabled == true) {
        m_chkAccl.setChecked(true);
    }

    if (m_blnLinearAcclEnabled == true) {
        m_chkLinearAccl.setChecked(true);
    }

    if (m_blnGravityEnabled == true) {
        m_chkGravity.setChecked(true);
    }

    if (m_blnGyroEnabled == true) {
        m_chkGyro.setChecked(true);
    }

    if (m_blnOrientEnabled == true) {
        m_chkOrient.setChecked(true);
    }

    if (m_blnMagnetEnabled == true) {
        m_chkMagnet.setChecked(true);
    }

    if (m_blnLightEnabled == true) {
        m_chkLight.setChecked(true);
    }

    if (m_blnBarometerEnabled == true) {
        m_chkBarometer.setChecked(true);
    }

    if (m_blnMicEnabled == true) {
        m_chkMic.setChecked(true);
    }

    if (m_blnCellularEnabled == true) {
        m_chkCellular.setChecked(true);
    }

    if (m_blnGPSEnabled == true) {
        m_chkGPS.setChecked(true);
    }

    if (m_blnWifiEnabled == true) {
        m_chkWifi.setChecked(true);
    }

    Settings.System.putInt(getContentResolver(), Settings.System.WIFI_SLEEP_POLICY,
            Settings.System.WIFI_SLEEP_POLICY_NEVER);

}

From source file:com.lgallardo.qbittorrentclient.RefreshListener.java

protected void getSettings() {
    // Preferences stuff
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);

    builderPrefs = new StringBuilder();

    builderPrefs.append("\n" + sharedPrefs.getString("language", "NULL"));

    // Get values from preferences
    currentServer = sharedPrefs.getString("currentServer", "1");
    hostname = sharedPrefs.getString("hostname", "");
    subfolder = sharedPrefs.getString("subfolder", "");

    protocol = sharedPrefs.getString("protocol", "NULL");

    // If user leave the field empty, set 8080 port
    try {//  ww w  .  ja  v a2  s .  c  o  m
        port = Integer.parseInt(sharedPrefs.getString("port", "8080"));
    } catch (NumberFormatException e) {
        port = 8080;

    }
    username = sharedPrefs.getString("username", "NULL");
    password = sharedPrefs.getString("password", "NULL");
    https = sharedPrefs.getBoolean("https", false);

    // Check https
    if (https) {
        protocol = "https";
    } else {
        protocol = "http";
    }

    // Get refresh info
    auto_refresh = sharedPrefs.getBoolean("auto_refresh", true);

    try {
        refresh_period = Integer.parseInt(sharedPrefs.getString("refresh_period", "120000"));
    } catch (NumberFormatException e) {
        refresh_period = 120000;
    }

    // Get connection and data timeouts
    try {
        connection_timeout = Integer.parseInt(sharedPrefs.getString("connection_timeout", "10"));

        // New default value to make it work with qBittorrent 3.2.x
        if (connection_timeout < 10) {
            connection_timeout = 10;
        }
    } catch (NumberFormatException e) {
        connection_timeout = 10;
    }

    try {
        data_timeout = Integer.parseInt(sharedPrefs.getString("data_timeout", "20"));

        // New default value to make it work with qBittorrent 3.2.x
        if (data_timeout < 20) {
            data_timeout = 20;
        }

    } catch (NumberFormatException e) {
        data_timeout = 20;
    }

    sortby_value = sharedPrefs.getInt("sortby_value", 1);
    reverse_order = sharedPrefs.getBoolean("reverse_order", false);

    dark_ui = sharedPrefs.getBoolean("dark_ui", false);

    qb_version = sharedPrefs.getString("qb_version", "3.2.x");

    MainActivity.cookie = sharedPrefs.getString("qbCookie", null);

    // Get last state
    lastState = sharedPrefs.getString("lastState", "all");

    // Get last label
    //        lastLabel = sharedPrefs.getString("lastLabel", "all");
    lastLabel = sharedPrefs.getString("lastLabel", "all");
    currentLabel = lastLabel;

    // Notification check
    enable_notifications = sharedPrefs.getBoolean("enable_notifications", false);

    try {
        notification_period = Long.parseLong(sharedPrefs.getString("notification_period", "120000L"));
    } catch (NumberFormatException e) {
        notification_period = 120000L;
    }

    header = sharedPrefs.getBoolean("header", true);

    // Get package info
    PackageInfo pInfo = null;
    try {
        pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    // Get package name
    packageName = pInfo.packageName;
    packageVersion = pInfo.versionName;

    // Get AlternativeSpeedLimitsEnabled value
    alternative_speeds = sharedPrefs.getBoolean("alternativeSpeedLimitsEnabled", false);

    // Get local SSID properties
    ssid = sharedPrefs.getString("ssid", "");
    local_hostname = sharedPrefs.getString("local_hostname", null);

    // If user leave the field empty, set 8080 port
    try {
        local_port = Integer.parseInt(sharedPrefs.getString("local_port", "-1"));
    } catch (NumberFormatException e) {
        local_port = -1;

    }

    // Set SSI and local hostname and port
    if (ssid != null && !ssid.equals("")) {

        // Get SSID if WiFi
        WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
        String wifiSSID = wifiInfo.getSSID();

        //            Log.d("Debug", "WiFi SSID: " + wifiSSID);
        //            Log.d("Debug", "SSID: " + ssid);

        if (wifiSSID.toUpperCase().equals("\"" + ssid.toUpperCase() + "\"")
                && wifiMgr.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {

            if (local_hostname != null && !local_hostname.equals("")) {
                hostname = local_hostname;
            }

            if (local_port != -1) {
                port = local_port;
            }

            //                Log.d("Debug", "hostname: " + hostname);
            //                Log.d("Debug", "port: " + port);
            //                Log.d("Debug", "local_hostname: " + local_hostname);
            //                Log.d("Debug", "local_port: " + local_port);

        }
    }

    // Get keystore for self-signed certificate
    keystore_path = sharedPrefs.getString("keystore_path" + currentServer, "");
    keystore_password = sharedPrefs.getString("keystore_password" + currentServer, "");

}

From source file:com.android.mms.ui.MessageUtils.java

public static boolean isWifiConnected(Context context) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo wifi = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    MmsLog.d(TAG, "wifi state:" + wifiManager.getWifiState() + "wifi connected:" + wifi.isConnected());
    if (wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED && wifi.isConnected()) {
        MmsLog.d(TAG, "Wifi connected");
        return true;
    }/* w  ww.j  a va2s . c  om*/
    MmsLog.d(TAG, "Wifi off or not connected");
    return false;
}