String data ="";
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WifiManager mainWifiObj;
mainWifiObj = (WifiManager) getSystemService(Context.WIFI_SERVICE);
class WifiScanReceiver extends BroadcastReceiver
{
public void onReceive(Context c, Intent intent)
{
}
}
WifiScanReceiver wifiReciever = new WifiScanReceiver();
registerReceiver(wifiReciever, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
List<ScanResult> wifiScanList = mainWifiObj.getScanResults(); int signalLevel =
0; StringBuilder sb = new StringBuilder();
data = wifiScanList.get(8).toString();
TextView tv = new TextView(this);
tv.setText(sb);
setContentView(tv);
}
handler.post(runnable);
I want to add my timer such that this code should run 5 times and it should run every 2 seconds. I am new to android. I found the timer code from the internet, but whenever and whichever code i try to implement, it gives me error. Basically, I think I am not adding the code at proper place.
但是,我不知道,我应该把它放在哪里。在 oncreate 方法或onCreate
方法之间应该是run()
.
我是新人所以问了这个问题。谁能帮帮我。
在这里,给出的答案运行但我无法打印代码