android wifimamger扫描所有可用的网络

时间:2015-09-02 14:17:27

标签: android wifimanager

我去创建一个应用程序,扫描Android手机应用程序中的所有可用网络必须一次又一次扫描网络,延迟5秒运行3分钟获取级别值,并给我平均水平值作为输出。有什么帮助吗?

handler = new Handler();
          handler.postDelayed(new Runnable() {
              public void run() {
                  task_repeart();
              }
          }, 5000);
public void task_repeart( )
    {
        repaert++;
        getWifiNetworksList(); // getWifiNetworksList does not give any output in this way other wise this function works perfect 
        if (repaert < 3  ){ // just for the test purposing i am call  getWifiNetworksList() just 3 time
        handler.postDelayed(new Runnable() {
              public void run() {
                  task_repeart();
              }
          }, 5000);
        }
    }
 private void getWifiNetworksList(){  
        IntentFilter filter = new IntentFilter(); 
        filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); 
        final WifiManager wifiManager =  (WifiManager)getApplicationContext().getSystemService(Context.WIFI_SERVICE);; 
        registerReceiver(new BroadcastReceiver(){ 
            @SuppressLint("UseValueOf") 

            @Override
            public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub
                sb = new StringBuilder(); 
                scanList = wifiManager.getScanResults(); 
                sb.append("\n Number Of Wifi connections :" + " " +scanList.size()+"\n\n");  
                for(int i = 0; i < scanList.size(); i++){
                    sb.append(new Integer(i+1).toString() + ". "); 
                    sb.append((scanList.get(i)).toString()); 
                    sb.append("\n\n"); }  tv.setText(sb);  
            }  
            },filter); 
        wifiManager.startScan(); 
        }

0 个答案:

没有答案