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()
.
私は新しいので、この質問をしました。誰でも私を助けてください。
ここで、与えられた答えは実行されますが、コードを印刷できません