我正在研究带有wifi指纹识别的室内定位系统,其中我想在arrryList中存储BSSID的具体级别我尝试了这段代码,但似乎没有工作
public class calibrate2 extends AppCompatActivity {
WifiManager wifimanager2;
Button cali;
Button reset;
//EditText Tx;
//EditText Ty;
TextView textView;
TextView textView2;
List<ScanResult> list;
Integer j,x,i=0;
ArrayList<String> Ap=new ArrayList<>();;
ArrayList<Integer> si=new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calibrate2);
Ap = getIntent().getStringArrayListExtra("ap");
cali = (Button) findViewById(R.id.button);
reset = (Button) findViewById(R.id.button2);
textView= (TextView)findViewById(R.id.textView);
textView2= (TextView)findViewById(R.id.textView2);
// Tx = (EditText) findViewById(R.id.editText);
// Ty = (EditText) findViewById(R.id.editText2);
wifimanager2 = (WifiManager) getSystemService(Context.WIFI_SERVICE);
cali.setOnClickListener(
new View.OnClickListener() {
public void onClick(View view) {
wifimanager2.startScan();
list = wifimanager2.getScanResults();
for (j = 0; j < Ap.size(); j++) {
for (i = 0; i < list.size(); i++) {
if (list.get(i).BSSID == Ap.get(j)) {
si.add(list.get(i).level);
break;
}
}
for (j = 0; j < Ap.size(); j++) {
textView2.append(si.get(j).toString());
textView2.append(" /n");
}
}
}
}
);
}}
我想这个问题出现在for循环中,因为活动工作正常,但每当我点击按钮就会转到父活动
答案 0 :(得分:0)
我现在得到了答案,这项改变正在发挥作用
` for (i = 0; i < list.size(); i++) {
if (Ap.get(j).contains(list.get(i).BSSID) {
si.add(list.get(i).level);
break;}}
for (j = 0; j <si.size(); j++) {
//change Ap.size()to si.size()
textView2.append(si.get(j).toString());
textView2.append(" /n");}