本文整理了Java中android.net.wifi.WifiManager.getScanResults()
方法的一些代码示例,展示了WifiManager.getScanResults()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WifiManager.getScanResults()
方法的具体详情如下:
包路径:android.net.wifi.WifiManager
类名称:WifiManager
方法名:getScanResults
暂无
代码示例来源:origin: stackoverflow.com
public void onReceive(Context c, Intent intent)
results = wifi.getScanResults();
size = results.size();
代码示例来源:origin: cSploit/android
@SuppressWarnings("ConstantConditions")
@Override
public void onReceive(Context context, Intent intent){
if(intent.getAction().equals(SCAN_RESULTS_AVAILABLE_ACTION)){
if(mScanning){
mAdapter.reset();
if(mMenu != null){
MenuItem menuScan = mMenu.findItem(R.id.scan);
MenuItemCompat.setActionView(menuScan, null);
}
List<ScanResult> results = mWifiManager.getScanResults();
for(ScanResult result : results){
mAdapter.addResult(result);
}
mScanning = false;
mStatusText.setText(getString(R.string.wifi_scan_finished));
}
mAdapter.notifyDataSetChanged();
}
}
}
代码示例来源:origin: facebook/facebook-android-sdk
private List<WifiScanResult> getCachedScanResults()
throws ScannerException {
try {
List<ScanResult> scanResults = wifiManager.getScanResults();
scanResults = filterWifiScanResultsByMaxAge(scanResults, params.getWifiScanMaxAgeMs());
filterResults(scanResults, params.getWifiMaxScanResults());
List<WifiScanResult> wifiScanResults = new ArrayList<>(scanResults.size());
for (ScanResult scanResult : scanResults) {
if (!isWifiSsidBlacklisted(scanResult.SSID)) {
WifiScanResult wifiScanResult = new WifiScanResult();
wifiScanResult.bssid = scanResult.BSSID;
wifiScanResult.ssid = scanResult.SSID;
wifiScanResult.rssi = scanResult.level;
wifiScanResult.frequency = scanResult.frequency;
if (Build.VERSION.SDK_INT >= ScannerFactory.OS_VERSION_JELLY_BEAN_MR1) {
wifiScanResult.timestampMs =
TimeUnit.MICROSECONDS.toMillis(scanResult.timestamp);
} else {
wifiScanResult.timestampMs = SystemClock.elapsedRealtime();
}
wifiScanResults.add(wifiScanResult);
}
}
return wifiScanResults;
} catch (Exception e) {
throw new ScannerException(ScannerException.Type.UNKNOWN_ERROR, e);
}
}
代码示例来源:origin: wangdan/AisenWeiBo
List<ScanResult> scanResultList = wm.getScanResults();
if (scanResultList != null && scanResultList.size() > 0) {
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldReturnSetScanResults() throws Exception {
List<ScanResult> scanResults = new ArrayList<>();
shadowOf(wifiManager).setScanResults(scanResults);
assertThat(wifiManager.getScanResults()).isSameAs(scanResults);
}
代码示例来源:origin: stackoverflow.com
IntentFilter i = new IntentFilter();
i.addAction (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
registerReceiver(new BroadcastReceiver(){
public void onReceive(Context c, Intent i){
// Code to execute when SCAN_RESULTS_AVAILABLE_ACTION event occurs
WifiManager w = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);
myScanResultHandler(w.getScanResults()); // your method to handle Scan results
if (ScanAsFastAsPossible) w.startScan(); // relaunch scan immediately
else { /* Schedule the scan to be run later here */}
}
}, i );
// Launch wifiscanner the first time here (it will call the broadcast receiver above)
WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
boolean a = wm.startScan();
代码示例来源:origin: mayubao/KuaiChuan
/**
* wifi扫描
*/
public void startScan(){
mWifiManager.startScan();
mScanResultList = mWifiManager.getScanResults();
mWifiConfigurations = mWifiManager.getConfiguredNetworks();
}
代码示例来源:origin: stackoverflow.com
String MAC = info.getMacAddress();
List<ScanResult> results = wifiManager.getScanResults();
ScanResult bestSignal = null;
int count = 1;
代码示例来源:origin: pwittchen/NetworkEvents
public List<ScanResult> getWifiScanResults() {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
return wifiManager.getScanResults();
}
}
代码示例来源:origin: leavesC/WifiFileTransfer
/**
* 开启Wifi扫描
*
* @param context 上下文
*/
public static List<ScanResult> getScanResults(Context context) {
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager == null) {
return null;
}
return wifiManager.getScanResults();
}
代码示例来源:origin: stackoverflow.com
WifiManager wifi= (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.startScan();
// get list of the results in object format ( like an array )
List<ScanResult> results = wifi.getScanResults();`
// loop that goes through list
for (ScanResult result : results) {
Toast.makeText(this, result.SSID + " " + result.level,
Toast.LENGTH_SHORT).show();
}
代码示例来源:origin: JackWHLiu/jackknife
public static List<ScanResult> getCurrentWifiScanResult(Context context) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
wifiManager.startScan();
return wifiManager.getScanResults();
}
代码示例来源:origin: stackoverflow.com
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
// Level of a Scan Result
List<ScanResult> wifiList = wifiManager.getScanResults();
for (ScanResult scanResult : wifiList) {
int level = WifiManager.calculateSignalLevel(scanResult.level, 5);
System.out.println("Level is " + level + " out of 5");
}
// Level of current connection
int rssi = wifiManager.getConnectionInfo().getRssi();
int level = WifiManager.calculateSignalLevel(rssi, 5);
System.out.println("Level is " + level + " out of 5");
代码示例来源:origin: renyuneyun/Easer
private List<WifiConfigurationWrapper> obtainWifiList() {
List<WifiConfigurationWrapper> list = new ArrayList<>();
if (wifiManager != null) {
List<ScanResult> scanResults = wifiManager.getScanResults();
for (ScanResult result : scanResults) {
list.add(new WifiConfigurationWrapper(result.SSID, result.BSSID));
}
}
return list;
}
代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer
private void scanResults() {
try {
if (wifiManager.startScan()) {
List<ScanResult> scanResults = wifiManager.getScanResults();
cache.add(scanResults);
}
} catch (Exception e) {
// critical error: do not die
}
}
代码示例来源:origin: 18Gray/CommonUtils
/**
* 扫描所有可用网络
* @param context
*/
public void startScan(Context context)
{
wifiManager.startScan();
// 得到扫描结果
mWifiList = wifiManager.getScanResults();
// 得到配置好的网络连接
mWifiConfiguration = wifiManager.getConfiguredNetworks();
}
代码示例来源:origin: LiqiNew/MyUtils
/**
* 开启扫描
* @return
*/
public OnWifiControllerListener startScan() {
mWifiManager.startScan();
// 得到扫描结果
mWifiList = mWifiManager.getScanResults();
// 得到配置好的网络连接
mWifiConfigurations = mWifiManager.getConfiguredNetworks();
return this;
}
代码示例来源:origin: stackoverflow.com
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (wifi.isWifiEnabled() == false) {
Toast.makeText(getApplicationContext(), "wifi is disabled..making it enabled", Toast.LENGTH_LONG).show();
wifi.setWifiEnabled(true);
}
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context c, Intent intent) {
wifi.getScanResults();
}
};
代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer
private void withWiFiManager() {
when(wifiManager.isWifiEnabled()).thenReturn(false);
when(wifiManager.startScan()).thenReturn(true);
when(wifiManager.getScanResults()).thenReturn(scanResults);
when(wifiManager.getConnectionInfo()).thenReturn(wifiInfo);
when(wifiManager.getConfiguredNetworks()).thenReturn(configuredNetworks);
}
代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer
private void verifyWiFiManager() {
verify(wifiManager).isWifiEnabled();
verify(wifiManager).setWifiEnabled(true);
verify(wifiManager).startScan();
verify(wifiManager).getScanResults();
verify(wifiManager).getConnectionInfo();
verify(wifiManager).getConfiguredNetworks();
}
内容来源于网络,如有侵权,请联系作者删除!