Java Code Examples for android.net.wifi.WifiInfo#getRssi()
The following examples show how to use
android.net.wifi.WifiInfo#getRssi() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SignalInfo.java From MobileInfo with Apache License 2.0 | 6 votes |
/** * wifi * * @param mContext * @return */ private static void getDetailsWifiInfo(Context mContext, SignalBean signalBean) { try { WifiInfo mWifiInfo = getWifiInfo(mContext); int ip = mWifiInfo.getIpAddress(); String strIp = "" + (ip & 0xFF) + "." + ((ip >> 8) & 0xFF) + "." + ((ip >> 16) & 0xFF) + "." + ((ip >> 24) & 0xFF); signalBean.setBssid(mWifiInfo.getBSSID()); signalBean.setSsid(mWifiInfo.getSSID().replace("\"", "")); signalBean.setnIpAddress(strIp); signalBean.setMacAddress(getMac(mContext)); signalBean.setNetworkId(mWifiInfo.getNetworkId()); signalBean.setLinkSpeed(mWifiInfo.getLinkSpeed() + "Mbps"); int rssi = mWifiInfo.getRssi(); signalBean.setRssi(rssi); signalBean.setLevel(calculateSignalLevel(rssi)); isWifiProxy(mContext, signalBean); signalBean.setSupplicantState(mWifiInfo.getSupplicantState().name()); signalBean.setnIpAddressIpv6(getNetIP()); } catch (Exception e) { Log.i(TAG, e.toString()); } }
Example 2
Source File: NetworkConnUtil.java From RairDemo with Apache License 2.0 | 6 votes |
/** * 获取Wifi的Rssi * * @param context * @return */ public static String getWifiRssi(Context context) { int asu = 85; try { final NetworkInfo network = ((ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo(); if (network != null && network.isAvailable() && network.isConnected()) { int type = network.getType(); if (type == ConnectivityManager.TYPE_WIFI) { WifiManager wifiManager = (WifiManager) context .getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { asu = wifiInfo.getRssi(); } } } } catch (Exception e) { e.printStackTrace(); } return asu + "dBm"; }
Example 3
Source File: DeviceInfo.java From Cangol-appcore with Apache License 2.0 | 6 votes |
public static int getWifiRssi(Context context) { int asu = 85; try { final NetworkInfo network = ((ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo(); if (network != null && network.isAvailable() && network.isConnected()) { final int type = network.getType(); if (type == ConnectivityManager.TYPE_WIFI) { final WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); final WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { asu = wifiInfo.getRssi(); } } } } catch (Exception e) { Log.e("getWifiRssi", "" + e.getMessage(), e); } return asu; }
Example 4
Source File: Net.java From HttpInfo with Apache License 2.0 | 5 votes |
@SuppressLint("MissingPermission") public static int getWifiRssi(Context context) { try { WifiManager mWifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); if (mWifiManager != null) { WifiInfo mWifiInfo = mWifiManager.getConnectionInfo(); return mWifiInfo.getRssi(); } } catch (Exception e) { //ignore } return 0; }
Example 5
Source File: DeviceNetworkStatus.java From product-emm with Apache License 2.0 | 5 votes |
private int getWifiSignalStrength() { if (wifiManager != null) { WifiInfo wifiInfo = wifiManager.getConnectionInfo(); return wifiInfo.getRssi(); } return -1; }
Example 6
Source File: PhoneUtils.java From Mobilyzer with Apache License 2.0 | 5 votes |
public int getWifiRSSI(){ WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { return wifiInfo.getRssi(); } return -1; }
Example 7
Source File: JNIUtilities.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static int[] getWifiInfo(){ try{ WifiManager wmgr=(WifiManager) ApplicationLoader.applicationContext.getSystemService(Context.WIFI_SERVICE); WifiInfo info=wmgr.getConnectionInfo(); return new int[]{info.getRssi(), info.getLinkSpeed()}; }catch(Exception ignore){} return null; }
Example 8
Source File: InformationCollector.java From open-rmbt with Apache License 2.0 | 5 votes |
@Override public void onReceive(final Context context, final Intent intent) { final String action = intent.getAction(); if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) { Log.d(DEBUG_TAG, "Wifi RSSI changed"); if (getNetwork() == NETWORK_WIFI) { final WifiInfo wifiInfo = wifiManager.getConnectionInfo(); final int rssi = wifiInfo.getRssi(); if (rssi != -1 && rssi >= ACCEPT_WIFI_RSSI_MIN) { final SignalItem signalItem = SignalItem.getWifiSignalItem(wifiInfo.getLinkSpeed(), rssi); if (InformationCollector.this.collectInformation) { signals.add(signalItem); } lastSignalItem.set(signalItem); signal.set(rssi); signalType.set(SINGAL_TYPE_WLAN); } } } }
Example 9
Source File: JNIUtilities.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static int[] getWifiInfo(){ try{ WifiManager wmgr=(WifiManager) ApplicationLoader.applicationContext.getSystemService(Context.WIFI_SERVICE); WifiInfo info=wmgr.getConnectionInfo(); return new int[]{info.getRssi(), info.getLinkSpeed()}; }catch(Exception ignore){} return null; }
Example 10
Source File: j.java From letv with Apache License 2.0 | 4 votes |
private List<k> d() { z.a(); if (!a()) { return new ArrayList(); } k kVar; WifiInfo connectionInfo = this.a.getConnectionInfo(); if (connectionInfo != null) { k kVar2 = new k(this, connectionInfo.getBSSID(), connectionInfo.getRssi(), connectionInfo.getSSID()); new StringBuilder(z[6]).append(kVar2.toString()); kVar = kVar2; z.a(); } else { kVar = null; } ArrayList arrayList = new ArrayList(); if (kVar != null) { arrayList.add(kVar); } List scanResults = VERSION.SDK_INT < 23 ? this.a.getScanResults() : (this.b == null || !a.c(this.b, z[5])) ? null : this.a.getScanResults(); if (r0 != null && r0.size() > 0) { int i = -200; k kVar3 = null; for (ScanResult kVar4 : r0) { int i2; k kVar5 = new k(this, kVar4); if (kVar5.c.equals(kVar.c) || kVar5.b <= i) { kVar2 = kVar3; i2 = i; } else { new StringBuilder(z[4]).append(kVar5.toString()); z.a(); k kVar6 = kVar5; i2 = kVar5.b; kVar2 = kVar6; } kVar3 = kVar2; i = i2; } if (kVar3 != null) { arrayList.add(kVar3); } } return arrayList; }
Example 11
Source File: InformationCollector.java From open-rmbt with Apache License 2.0 | 4 votes |
private void getWiFiInfo() { initNetwork(); if (wifiManager != null) { final WifiInfo wifiInfo = wifiManager.getConnectionInfo(); fullInfo.setProperty("WIFI_SSID", String.valueOf(Helperfunctions.removeQuotationsInCurrentSSIDForJellyBean(wifiInfo.getSSID()))); /* * fullInfo.setProperty("WIFI_LINKSPEED", * String.valueOf(wifiInfo.getLinkSpeed())); */ fullInfo.setProperty("WIFI_BSSID", String.valueOf(wifiInfo.getBSSID())); fullInfo.setProperty("WIFI_NETWORK_ID", String.valueOf(wifiInfo.getNetworkId())); /* * fullInfo.setProperty("WIFI_RSSI", * String.valueOf(wifiInfo.getRssi())); */ final SupplicantState wifiState = wifiInfo.getSupplicantState(); fullInfo.setProperty("WIFI_SUPPLICANT_STATE", String.valueOf(wifiState.name())); final DetailedState wifiDetail = WifiInfo.getDetailedStateOf(wifiState); fullInfo.setProperty("WIFI_SUPPLICANT_STATE_DETAIL", String.valueOf(wifiDetail.name())); if (getNetwork() == NETWORK_WIFI) { final int rssi = wifiInfo.getRssi(); if (rssi != -1 && rssi >= ACCEPT_WIFI_RSSI_MIN) { int linkSpeed = wifiInfo.getLinkSpeed(); if (linkSpeed < 0) { linkSpeed = 0; } final SignalItem signalItem = SignalItem.getWifiSignalItem(linkSpeed, rssi); if (this.collectInformation) { signals.add(signalItem); } lastSignalItem.set(signalItem); signal.set(rssi); signalType.set(SINGAL_TYPE_WLAN); // Log.i(DEBUG_TAG, "Signals1: " + signals.toString()); } } } }
Example 12
Source File: Wifi.java From batteryhub with Apache License 2.0 | 2 votes |
/** * Get current WiFi signal Strength. * * @param context The Context * @return Signal strength */ public static int getSignalStrength(Context context) { WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = manager.getConnectionInfo(); return wifiInfo.getRssi(); }