返回值等待广播接收器?

时间:2018-11-02 06:49:31

标签: java android hashset

比方说,我有一个计时器,每个间隔运行60秒,要求getBssid(),返回值是否取决于首先接收的广播接收器?因为我的广播接收器在HashSet中设置了一个值,而getBssid()是要检索HashSet

getBssid:

static String getBSSID() {

        return TextUtils.join(",",idsSet);
    }

广播接收器:

 private BroadcastReceiver wifiReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            idsSet.clear();
            List<ScanResult> results = wifiManager.getScanResults();
            for (ScanResult scanResult : results) {
                String scanWifi = scanResult.SSID;
                if (scanWifi.startsWith(ConfigurationManager.configuration.getEssidPrefix())) {
                    idsSet.add(scanResult.BSSID);
                }
            }

            wifiUpdates();
        }
    };

如果是这样,如何在不等待广播接收器的情况下随时检索HashSet?

0 个答案:

没有答案