當前位置: 首頁>>代碼示例>>Java>>正文


Java ScanResult類代碼示例

本文整理匯總了Java中android.net.wifi.ScanResult的典型用法代碼示例。如果您正苦於以下問題:Java ScanResult類的具體用法?Java ScanResult怎麽用?Java ScanResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ScanResult類屬於android.net.wifi包,在下文中一共展示了ScanResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getWifiConfiguration

import android.net.wifi.ScanResult; //導入依賴的package包/類
@Nullable
static WifiConfiguration getWifiConfiguration(@NonNull final WifiManager wifiMgr, @NonNull final ScanResult scanResult) {
    if (scanResult.BSSID == null || scanResult.SSID == null || scanResult.SSID.isEmpty() || scanResult.BSSID.isEmpty())
        return null;
    final String ssid = convertToQuotedString(scanResult.SSID);
    final String bssid = scanResult.BSSID;
    final String security = getSecurity(scanResult);

    final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
    if (configurations == null)
        return null;

    for (final WifiConfiguration config : configurations) {
        if (bssid.equals(config.BSSID) || ssid.equals(config.SSID)) {
            final String configSecurity = getSecurity(config);
            if (Objects.equals(security, configSecurity))
                return config;
        }
    }
    return null;
}
 
開發者ID:ThanosFisherman,項目名稱:WifiUtils,代碼行數:22,代碼來源:ConfigSecurities.java

示例2: disableAllButOne

import android.net.wifi.ScanResult; //導入依賴的package包/類
@SuppressWarnings("UnusedReturnValue")
private static boolean disableAllButOne(@NonNull final WifiManager wifiManager, @Nullable final ScanResult scanResult) {
    @Nullable final List<WifiConfiguration> configurations = wifiManager.getConfiguredNetworks();
    if (configurations == null || scanResult == null || configurations.isEmpty())
        return false;
    boolean result = false;
    for (WifiConfiguration wifiConfig : configurations)
        if (Objects.equals(scanResult.BSSID, wifiConfig.BSSID) && Objects.equals(scanResult.SSID, trimQuotes(wifiConfig.SSID)))
            result = wifiManager.enableNetwork(wifiConfig.networkId, true);
        else
            wifiManager.disableNetwork(wifiConfig.networkId);
    return result;
}
 
開發者ID:ThanosFisherman,項目名稱:WifiUtils,代碼行數:14,代碼來源:ConnectorUtils.java

示例3: onReceive

import android.net.wifi.ScanResult; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent)
{
    WifiManager wifiMgr = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
    String name = wifiInfo.getSSID();
    for(ScanResult result: wifiMgr.getScanResults()){
        WifiApListProvider.this.output(new WifiAp(result, name.equals(result.SSID)));
    }
    WifiApListProvider.this.finish();
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:12,代碼來源:WifiApListProvider.java

示例4: getCipherType

import android.net.wifi.ScanResult; //導入依賴的package包/類
public static WifiCipherType getCipherType(Context context, String ssid) {
    WifiManager wifiManager = (WifiManager) context
            .getSystemService(Context.WIFI_SERVICE);

    List<ScanResult> list = wifiManager.getScanResults();

    for (ScanResult scResult : list) {

        if (!StringUtils.isEmpty(scResult.SSID) && scResult.SSID.equals(ssid)) {
            String capabilities = scResult.capabilities;

            if (!StringUtils.isEmpty(capabilities)) {

                if (capabilities.contains("WPA")
                        || capabilities.contains("wpa")) {
                    LogUtils.i("wpa");
                    return WifiCipherType.WIFICIPHER_WPA;
                } else if (capabilities.contains("WEP")
                        || capabilities.contains("wep")) {
                    LogUtils.i("wep");
                    return WifiCipherType.WIFICIPHER_WEP;
                } else {
                    LogUtils.i("no");
                    return WifiCipherType.WIFICIPHER_NOPASS;
                }
            }
        }
    }
    return WifiCipherType.WIFICIPHER_INVALID;
}
 
開發者ID:Horrarndoo,項目名稱:YiZhi,代碼行數:31,代碼來源:WifiAutoConnectManager.java

示例5: onWiFisChanged

import android.net.wifi.ScanResult; //導入依賴的package包/類
/**
 * Call back method entered when Android has completed a scan for WiFi emitters in
 * the area.
 */
private void onWiFisChanged() {
    if ((wm != null) && (emitterCache != null)) {
        List<ScanResult> scanResults = wm.getScanResults();
        Set<Observation> observations = new HashSet<Observation>();
        for (ScanResult sr : scanResults) {
            String bssid = sr.BSSID.toLowerCase(Locale.US).replace(".", ":");
            if (bssid != null) {
                Observation o = new Observation(bssid, RfEmitter.EmitterType.WLAN);

                o.setAsu(WifiManager.calculateSignalLevel(sr.level, MAXIMUM_ASU));
                o.setNote(sr.SSID);
                observations.add(o);
            }
        }
        if (!observations.isEmpty()) {
            // Log.d(TAG, "onWiFisChanged(): Observations: " + observations.toString());
            queueForProcessing(observations, RfEmitter.EmitterType.WLAN, System.currentTimeMillis());
        }
    }
}
 
開發者ID:n76,項目名稱:DejaVu,代碼行數:25,代碼來源:BackendService.java

示例6: getScanResultsByBSSID

import android.net.wifi.ScanResult; //導入依賴的package包/類
public static ScanResult getScanResultsByBSSID(Context context, String bssid) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    ScanResult scanResult = null;
    boolean f = wifiManager.startScan();
    if (!f) {
        getScanResultsByBSSID(context, bssid);
    }
    List<ScanResult> list = wifiManager.getScanResults();
    if (list != null) {
        for (int i = 0; i < list.size(); i++) {
            scanResult = list.get(i);
            if (scanResult.BSSID.equals(bssid)) {
                break;
            }
        }
    }
    return scanResult;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:19,代碼來源:NetUtils.java

示例7: a

import android.net.wifi.ScanResult; //導入依賴的package包/類
public final void a(int i, int i2, int i3, int i4, List<ScanResult> list) {
    this.b = System.currentTimeMillis();
    this.e = null;
    this.c.clear();
    a aVar = new a();
    aVar.a = i;
    aVar.b = i2;
    aVar.c = i3;
    aVar.d = i4;
    this.c.add(aVar);
    if (list != null) {
        this.d.clear();
        for (int i5 = 0; i5 < list.size(); i5++) {
            b bVar = new b();
            bVar.a = ((ScanResult) list.get(i5)).BSSID;
            int i6 = ((ScanResult) list.get(i5)).level;
            this.d.add(bVar);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:21,代碼來源:c.java

示例8: wifiConnection

import android.net.wifi.ScanResult; //導入依賴的package包/類
public static boolean wifiConnection(Context context, String wifiSSID, String password) {
    WifiManager wifi = (WifiManager) context.getSystemService("wifi");
    String strQuotationSSID = "\"" + wifiSSID + "\"";
    WifiInfo wifiInfo = wifi.getConnectionInfo();
    if (wifiInfo != null && (wifiSSID.equals(wifiInfo.getSSID()) || strQuotationSSID.equals(wifiInfo.getSSID()))) {
        return true;
    }
    List<ScanResult> scanResults = wifi.getScanResults();
    if (scanResults == null || scanResults.size() == 0) {
        return false;
    }
    for (int nAllIndex = scanResults.size() - 1; nAllIndex >= 0; nAllIndex--) {
        String strScanSSID = ((ScanResult) scanResults.get(nAllIndex)).SSID;
        if (wifiSSID.equals(strScanSSID) || strQuotationSSID.equals(strScanSSID)) {
            WifiConfiguration config = new WifiConfiguration();
            config.SSID = strQuotationSSID;
            config.preSharedKey = "\"" + password + "\"";
            config.status = 2;
            return wifi.enableNetwork(wifi.addNetwork(config), false);
        }
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:24,代碼來源:NetworkHelper.java

示例9: getWifiList

import android.net.wifi.ScanResult; //導入依賴的package包/類
/**
 * wifi列表
 */
private void getWifiList() {
    if (isWifiContect() && !stopScanWifi) {
        if (mWifiManager.getConnectionInfo().getSSID().contains("Photon-") && mWifiManager.getConnectionInfo().getSSID().length() == 11) {
            connectWifi(mWifiManager.getConnectionInfo().getSSID());
            return;
        }
        Log.d("XLight", "get scan wifi result");
        //獲取結果
        List<ScanResult> wifiScanList = mWifiManager.getScanResults();
        //查看是否存在Photon-xxxx
        for (ScanResult sr : wifiScanList) {
            if (sr.SSID.contains("Photon-") && sr.SSID.length() == 11) {
                connectWifi(sr.SSID);
            }
        }
    }
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:21,代碼來源:BindDeviceSearchActivity.java

示例10: getView

import android.net.wifi.ScanResult; //導入依賴的package包/類
@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (null == convertView) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.layout_wifi_list_item, null);

            holder.ssid = (TextView) convertView.findViewById(R.id.ssid);
            holder.lockIcon = (ImageView) convertView.findViewById(R.id.lockIcon);

            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        ScanResult wifiInfo = mScanResultList.get(position);
        holder.ssid.setText(wifiInfo.SSID);
//        holder.lockIcon.setVisibility(0 == deviceInfo.maindevice ? View.GONE : View.VISIBLE);

        return convertView;
    }
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:23,代碼來源:WifiListAdapter.java

示例11: loadInBackground

import android.net.wifi.ScanResult; //導入依賴的package包/類
@Override
public Set<ScanResultNetwork> loadInBackground() {
    List<ScanResult> scanResults = wifiFacade.getScanResults();
    log.d("Latest (unfiltered) scan results: " + scanResults);

    if (loadCount % 3 == 0) {
        wifiFacade.startScan();
    }

    loadCount++;
    // filter the list, transform the matched results, then wrap those in a Set
    mostRecentResult = set(Funcy.transformList(
            scanResults, ssidStartsWithProductName, ScanResultNetwork::new));

    if (mostRecentResult.isEmpty()) {
        log.i("No SSID scan results returned after filtering by product name.  " +
                "Do you need to change the 'network_name_prefix' resource?");
    }

    return mostRecentResult;
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:22,代碼來源:WifiScanResultLoader.java

示例12: getWifiListNearby

import android.net.wifi.ScanResult; //導入依賴的package包/類
public List<Map<String, String>> getWifiListNearby() {
    List<Map<String, String>> arrayList = new ArrayList();
    if (this.a == null) {
        return arrayList;
    }
    WifiManager wifiManager = (WifiManager) this.a.getSystemService("wifi");
    if (wifiManager == null) {
        return arrayList;
    }
    List<ScanResult> scanResults = wifiManager.getScanResults();
    if (scanResults == null) {
        return arrayList;
    }
    for (ScanResult scanResult : scanResults) {
        Map hashMap = new HashMap();
        hashMap.put("wifiMac", scanResult.BSSID == null ? "" : scanResult.BSSID);
        hashMap.put("ssid", scanResult.SSID);
        hashMap.put("rssi", scanResult.level);
        arrayList.add(hashMap);
    }
    return arrayList;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:LocationInfo.java

示例13: getView

import android.net.wifi.ScanResult; //導入依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;

    if (convertView == null) {
        holder = new ViewHolder();
        convertView = inflater.inflate(R.layout.wifi_list, null);
        holder.wifiName = (TextView) convertView.findViewById(R.id.wifi_name);
        convertView.setTag(holder);

    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    ScanResult scanResult = list.get(position);
    holder.wifiName.setText(scanResult.SSID);
    return convertView;
}
 
開發者ID:stewForAni,項目名稱:Lamp,代碼行數:19,代碼來源:WifiConnectActivity.java

示例14: getAvailableAPList

import android.net.wifi.ScanResult; //導入依賴的package包/類
public static ArrayList<String> getAvailableAPList(Context context) {
    ArrayList<String> apList = new ArrayList<String>();
    try {
        isNtutccAround = false;
        WifiManager wifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        List<ScanResult> scanResults = wifiManager.getScanResults();
        for (ScanResult result : scanResults) {
            apList.add(result.SSID + ":" + result.level + "dBm");
            if (result.SSID.equals("ntutcc")) {
                isNtutccAround = true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return apList;
}
 
開發者ID:kamisakihideyoshi,項目名稱:TaipeiTechRefined,代碼行數:19,代碼來源:WifiUtility.java

示例15: onScanResultsAvailable

import android.net.wifi.ScanResult; //導入依賴的package包/類
@Override
public void onScanResultsAvailable(List<ScanResult> scanResults) {
    onConnectionStateChanged(AdvancedConnectionState.SCAN_RESULTS_AVAILABLE);

    availableSSID = wifiHelper.findAvailableSSID(SSIDs, scanResults);
    if (reentrantLock.tryLock()) {
        wifiUtil.removeWifiScanResultsListener(this);

        if (availableSSID != null) {
            onSSIDAvailable(availableSSID);
        } else {
            String reason = "Couldn't find SSID in which we are interested";
            connectionStateListener.onConnectionError(reason);
            LOGGER.i(reason);
        }
    }
}
 
開發者ID:nishkarsh,項目名稱:android-wificonnect,代碼行數:18,代碼來源:WifiConnectionManager.java


注:本文中的android.net.wifi.ScanResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。