我正在尝试制作一个寻找WiFi网络并连接到它们的简单应用。我目前在更新UI时遇到问题。
一些指针会很棒。感谢您的时间。
class UiUpdater extends AsyncTask<Void, Void, List<ScanResult>> {
@Override
protected void onPreExecute() {
super.onPreExecute();
TextView searching = (TextView) findViewById(R.id.searching);
searching.setText("Currently searching...");
}
@Override
protected List<ScanResult> doInBackground(Void... params) {
WifiManager manager = (WifiManager) Client.this.getSystemService(Context.WIFI_SERVICE);
if (!manager.isWifiEnabled())
manager.setWifiEnabled(true);
return manager.getScanResults();
}
@Override
protected void onPostExecute(List<ScanResult> items) {
super.onPostExecute(items);
ArrayList<Items> wifi = new ArrayList<>();
for (ScanResult s : items)
wifi.add(new Items(s.SSID, s.capabilities));
///TextView searching = (TextView) findViewById(R.id.searching);
///searching.setText("");
ListView list = (ListView) findViewById(R.id.list);
Explorer adapter = new Explorer(Client.this, R.layout.listview_item_row, wifi);
list.setAdapter(adapter);
clickListener(list, wifi);
}
}
最佳答案
请使用Toast消息或logcat或断点检查onPost执行是否被调用