Android:如何获取禁用GPS的所有wifi BSSID

问题描述 投票:1回答:1

通过此示例和gps禁用,我没有得到ScanResults。启用gps后我会得到结果。(在Android 7上测试)我必须启用gps是正常的吗?有没有办法在没有GPS的情况下获得所有wifi的BSSID?

public void readWifis(Activity activity) {

    // Get the wifi manager.
    // Provides the primary API for managing all aspects of Wi-Fi connectivity.
    WifiManager wifiManager = (WifiManager) activity.getApplicationContext().getSystemService(Context.WIFI_SERVICE);

    activity.registerReceiver(new BroadcastReceiver() {
                                  @Override
                                  public void onReceive(Context c, Intent intent) {
                                      List<ScanResult> results = wifiManager.getScanResults();
                                      for (ScanResult ap : results) {
                                          Log.d("myTag", "SSID=" + ap.SSID + " MAC=" + ap.BSSID);
                                      }
                                  }
                              },
            // An access point scan has completed, and results are available from the supplicant. Call getScanResults() to obtain the results.
            new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));


    // Request a scan for access points.
    wifiManager.startScan();

}
android gps
1个回答
0
投票

您必须启用GPS,但根据请求的位置使用GPS,Wi-Fi或移动网络的位置服务。

BSSID和SSID的问题在于,它们被认为是位置信息,因此不仅要求用户授予位置许可(因为Android 8.1),而且还要求启用位置服务。

© www.soinside.com 2019 - 2024. All rights reserved.