android.net.wifi.WifiManager.isScanAlwaysAvailable()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(408)

本文整理了Java中android.net.wifi.WifiManager.isScanAlwaysAvailable()方法的一些代码示例,展示了WifiManager.isScanAlwaysAvailable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WifiManager.isScanAlwaysAvailable()方法的具体详情如下:
包路径:android.net.wifi.WifiManager
类名称:WifiManager
方法名:isScanAlwaysAvailable

WifiManager.isScanAlwaysAvailable介绍

暂无

代码示例

代码示例来源:origin: facebook/facebook-android-sdk

private boolean isWifiScanningAlwaysOn() {
  if (Build.VERSION.SDK_INT >= ScannerFactory.OS_VERSION_JELLY_BEAN_MR2) {
    return wifiManager.isScanAlwaysAvailable();
  }
  return false;
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = JELLY_BEAN_MR2)
public void getIsScanAlwaysAvailable() {
 shadowOf(wifiManager).setIsScanAlwaysAvailable(true);
 assertThat(wifiManager.isScanAlwaysAvailable()).isEqualTo(true);
 shadowOf(wifiManager).setIsScanAlwaysAvailable(false);
 assertThat(wifiManager.isScanAlwaysAvailable()).isEqualTo(false);
}

代码示例来源:origin: n76/wifi_backend

public static boolean isScanAlwaysAvailable(WifiManager wifiManager) {
    try {
      return wifiManager.isScanAlwaysAvailable();
    } catch (NoSuchMethodError e) {
      return false;
    }
  }
}

代码示例来源:origin: microg/android_external_UnifiedNlpApi

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private boolean isScanAlwaysAvailable() {
  return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2
      && wifiManager.isScanAlwaysAvailable();
}

代码示例来源:origin: n76/DejaVu

/**
 * Ask Android's WiFi manager to scan for access points (APs). When done the onWiFisChanged()
 * method will be called by Android.
 */
private void startWiFiScan() {
  // Throttle scanning for WiFi APs. In open terrain an AP could cover a kilometer.
  // Even in a vehicle moving at highway speeds it can take several seconds to traverse
  // the coverage area, no need to waste phone resources scanning too rapidly.
  long currentProcessTime = System.currentTimeMillis();
  if (currentProcessTime < nextWlanScanTime)
    return;
  nextWlanScanTime = currentProcessTime + WLAN_SCAN_INTERVAL;
  if (wm == null) {
    wm = (WifiManager) this.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
  }
  if ((wm != null)  && !wifiScanInprogress) {
    if (wm.isWifiEnabled() ||
        ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) && wm.isScanAlwaysAvailable())) {
      //Log.d(TAG,"startWiFiScan() - Starting WiFi collection.");
      wifiScanInprogress = true;
      wm.startScan();
    }
  }
}

代码示例来源:origin: IndoorAtlas/android-sdk-examples

/**
 * Check that WiFi is supported and background scanning is enabled
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public void onCheckWiFiBackgroundScanning(View view) {
  WifiManager manager = (WifiManager) getApplicationContext()
      .getSystemService(Context.WIFI_SERVICE);
  if (manager == null) {
    ExampleUtils.showInfo(this, getString(R.string.wifi_not_supported));
  } else {
    if (manager.isScanAlwaysAvailable()) {
      ExampleUtils.showInfo(this, getString(R.string.wifi_background_scanning_enabled));
    } else {
      // Ask user to enable background scanning
      startActivityForResult(
          new Intent(WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE),
          WIFI_BACKGROUND_SCANNING_ENABLED_REQUEST_CODE);
    }
  }
}

代码示例来源:origin: openbmap/radiocells-scanner-android

if (!mWifiManager.isWifiEnabled() && !mWifiManager.isScanAlwaysAvailable()) {
  Log.i(TAG, "Wifi disabled or is scan always available off, skipping wifi scan");
  return;

相关文章