List of usage examples for android.net.wifi WifiInfo getSSID
public String getSSID()
From source file:org.wahtod.wififixer.ui.StatusFragment.java
private void refresh() { WifiInfo info = getNetwork(getContext()); if (info == null) { _views.setSsid(getContext().getString(R.string.wifi_is_disabled)); _views.setSignal(EMPTYSTRING);//w ww . j av a 2 s . c o m _views.setLinkspeed(EMPTYSTRING); _views.setStatus(EMPTYSTRING); _views.setIcon(R.drawable.icon); } else if (info.getRssi() == -200) { _views.setSsid(EMPTYSTRING); _views.setSignal(EMPTYSTRING); _views.setLinkspeed(EMPTYSTRING); _views.setIcon(R.drawable.icon); } else { _views.setSsid(StringUtil.removeQuotes(info.getSSID())); _views.setSignal(String.valueOf(info.getRssi()) + DBM); _views.setLinkspeed(String.valueOf(info.getLinkSpeed()) + MB); _views.setStatus(info.getSupplicantState().name()); _views.setIcon(NotifUtil.getIconfromSignal(WifiManager.calculateSignalLevel(info.getRssi(), 5), NotifUtil.ICON_SET_LARGE)); } drawhandler.sendEmptyMessageDelayed(REFRESH, REFRESH_DELAY); }
From source file:org.pidome.client.services.aidl.service.SystemServiceAidl.java
private void setHome() { if (prefs != null) { if (prefs.getBoolPreference("wifiConnectHomeEnabled", false)) { ConnectivityManager connManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connManager.getActiveNetworkInfo(); if (networkInfo.isConnected() && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) { final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); final WifiInfo connectionInfo = wifiManager.getConnectionInfo(); if (connectionInfo != null) { String SSID = connectionInfo.getSSID(); String BSSID = connectionInfo.getBSSID(); if (SSID != null && BSSID != null) { if (SSID.equals(prefs.getStringPreference("wifiConnectSSID", java.util.UUID.randomUUID().toString())) && BSSID.equals(prefs.getStringPreference("wifiConnectBSSID", java.util.UUID.randomUUID().toString()))) { singleThreadfPipeExecutor.execute((Runnable) () -> { int i = SystemServiceAidl.this.clientCallBackList.beginBroadcast(); while (i > 0) { i--; try { clientCallBackList.beginBroadcast(); clientCallBackList.getBroadcastItem(i).updateUserPresence(1); clientCallBackList.finishBroadcast(); } catch (RemoteException ex) { Logger.getLogger(SystemServiceAidl.class.getName()).log(Level.SEVERE, null, ex); }/* w ww.j a v a 2 s . c om*/ } }); localizationService.setHome(true); } else { localizationService.setHome(false); } } } } else if (networkInfo.isConnected() && networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { localizationService.setHome(false); } } } }
From source file:com.entertailion.android.dial.ServerFinder.java
private String getNetworkName() { if (isSimulator()) { return "generic"; }/* w w w.ja v a2 s . co m*/ if (!isWifiAvailable()) { return null; } WifiInfo info = wifiManager.getConnectionInfo(); return info != null ? info.getSSID() : null; }
From source file:uk.bowdlerize.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.action_add: { AlertDialog.Builder builder = new AlertDialog.Builder(this); // Get the layout inflater LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.dialog_add_url, null); final EditText urlET = (EditText) dialogView.findViewById(R.id.urlET); builder.setView(dialogView)//from w w w . ja va 2s . co m .setPositiveButton(R.string.action_add, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Bundle extras = new Bundle(); Intent receiveURLIntent = new Intent(MainActivity.this, CensorCensusService.class); extras.putString("url", urlET.getText().toString()); extras.putString("hash", MD5(urlET.getText().toString())); extras.putInt("urgency", 0); extras.putBoolean("local", true); //Add our extra info if (getSharedPreferences(MainActivity.class.getSimpleName(), Context.MODE_PRIVATE) .getBoolean("sendISPMeta", true)) { WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiMgr.getConnectionInfo(); TelephonyManager telephonyManager = ((TelephonyManager) getSystemService( Context.TELEPHONY_SERVICE)); if (wifiMgr.isWifiEnabled() && null != wifiInfo.getSSID()) { LocalCache lc = null; Pair<Boolean, String> seenBefore = null; try { lc = new LocalCache(MainActivity.this); lc.open(); seenBefore = lc.findSSID(wifiInfo.getSSID().replaceAll("\"", "")); } catch (Exception e) { e.printStackTrace(); } if (null != lc) lc.close(); if (seenBefore.first) { extras.putString("isp", seenBefore.second); } else { extras.putString("isp", "unknown"); } try { extras.putString("sim", telephonyManager.getSimOperatorName()); } catch (Exception e) { e.printStackTrace(); } } else { try { extras.putString("isp", telephonyManager.getNetworkOperatorName()); } catch (Exception e) { e.printStackTrace(); } try { extras.putString("sim", telephonyManager.getSimOperatorName()); } catch (Exception e) { e.printStackTrace(); } } } receiveURLIntent.putExtras(extras); startService(receiveURLIntent); dialog.cancel(); } }).setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.show(); return true; } } return super.onOptionsItemSelected(item); }
From source file:com.tml.sharethem.receiver.ReceiverActivity.java
private void connectToWifi(String ssid) { WifiInfo info = wifiManager.getConnectionInfo(); unRegisterForScanResults();// www. j a v a 2 s.co m if (isOreoOrAbove()) { promptToConnectManually(ssid); return; } boolean resetWifiScan; if (info.getSSID().equals(ssid)) { Log.d(TAG, "Already connected to ShareThem, add sender Files listing fragment"); resetWifiScan = false; addSenderFilesListingFragment(WifiUtils.getAccessPointIpAddress(getApplicationContext()), ssid); } else { m_p2p_connection_status.setText(getString(R.string.p2p_receiver_connecting_hint, ssid)); resetWifiScan = !connectToOpenWifi(wifiManager, ssid, false); Log.e(TAG, "connection attempt to ShareThem wifi is " + (!resetWifiScan ? "success!!!" : "FAILED..!!!")); } //if wap isnt successful, start wifi scan if (resetWifiScan) { Toast.makeText(this, getString(R.string.p2p_receiver_error_in_connecting, ssid), Toast.LENGTH_SHORT) .show(); m_p2p_connection_status.setText(getString(R.string.p2p_receiver_scanning_hint)); startSenderScan(); } else { Message message = m_wifiScanHandler.obtainMessage(WAIT_FOR_CONNECT_ACTION_TIMEOUT); message.obj = ssid; m_wifiScanHandler.sendMessageDelayed(message, 7000); } }
From source file:com.google.android.apps.tvremote.DeviceFinder.java
private String getNetworkName() { if (!isWifiAvailable()) { return null; }//from w w w. j a va 2 s . c om WifiInfo info = wifiManager.getConnectionInfo(); return info != null ? info.getSSID() : null; }
From source file:org.universAAL.android.services.MiddlewareService.java
/** * Sets the current active WiFi connection as the network where "our" AAL * Space is located./*from w w w. j a v a2 s . com*/ */ private void thisIsOurWifi() { // if (isWifiOn()) { WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); String networkId = wifiInfo.getSSID(); PreferenceManager.getDefaultSharedPreferences(this).edit().putString(AppConstants.MY_WIFI, networkId) .commit(); Log.i(TAG, "Setting home space Wifi: " + networkId); // } }
From source file:fr.inria.ucn.collectors.NetworkStateCollector.java
private JSONObject getWifi(Context c) throws JSONException { WifiManager wm = (WifiManager) c.getSystemService(Context.WIFI_SERVICE); WifiInfo wi = wm.getConnectionInfo(); // start a wifi AP scan Helpers.acquireWifiLock(c);/*ww w.ja va2 s . c o m*/ IntentFilter filter = new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); c.registerReceiver(this, filter); wm.startScan(); JSONObject o = new JSONObject(); o.put("link_speed", wi.getLinkSpeed()); o.put("link_speed_units", WifiInfo.LINK_SPEED_UNITS); o.put("signal_level", WifiManager.calculateSignalLevel(wi.getRssi(), 100)); o.put("rssi", wi.getRssi()); o.put("bssid", wi.getBSSID()); o.put("ssid", wi.getSSID().replaceAll("\"", "")); o.put("mac", wi.getMacAddress()); int ip = wi.getIpAddress(); String ipstr = String.format(Locale.US, "%d.%d.%d.%d", (ip & 0xff), (ip >> 8 & 0xff), (ip >> 16 & 0xff), (ip >> 24 & 0xff)); o.put("ip", ipstr); return o; }
From source file:com.mobilyzer.util.PhoneUtils.java
public String getWifiSSID() { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { return wifiInfo.getSSID(); }/* w ww . jav a2 s.c o m*/ return null; }
From source file:com.mobilyzer.util.PhoneUtils.java
/** Returns current Wi-Fi SSID, or null if Wi-Fi is not connected. */ private String getWifiCarrierName() { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { return wifiInfo.getSSID(); }/* ww w. jav a 2s . c o m*/ return null; }