List of usage examples for android.net.wifi WifiInfo getSSID
public String getSSID()
From source file:ua.mkh.settings.full.MainActivity.java
private void ButtonTextWifi() { TextView textwifi = (TextView) findViewById(R.id.textwifi); if (wifi.isWifiEnabled()) { textwifi.setText(R.string.on);/*from w ww . j ava2 s .c om*/ } else { textwifi.setText(R.string.off); } WifiManager manager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE); if (manager.isWifiEnabled()) { WifiInfo wifiInfo = manager.getConnectionInfo(); if (wifiInfo != null) { DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState()); if (state == DetailedState.CONNECTED || state == DetailedState.OBTAINING_IPADDR) { String wi = wifiInfo.getSSID().replace('"', ' '); textwifi.setText(wi); } } } }
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 {// w ww. j ava2 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, ""); }