当前位置: 首页>>代码示例>>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;未经允许,请勿转载。