0
我知道我可以抓住BT扫描的结果,以这样代码的ArrayList:如何将蓝牙扫描结果保存在字符串数组中?
// Create a BroadcastReceiver for ACTION_FOUND
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// Add the name and address to an array adapter to show in a ListView
mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}
};
// Register the BroadcastReceiver
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
,但我想以后使用的结果,就像把他们一个字符串数组或类似这样的 东西上能不能做到?
我试着像做一个for循环,每次将结果放入一个数组[],但应用程序将卡住。你能告诉我一个例子吗? – user2141340 2013-03-23 20:59:26
您如何向我展示您的阵列尝试? – WarrenFaith 2013-03-24 14:06:36