Receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
switch(action) {
case BluetoothAdapter.ACTION_DISCOVERY_STARTED:
Toast.makeText(getApplicationContext(), "블루투스 검색 시작", Toast.LENGTH_SHORT).show();
break;
case BluetoothDevice.ACTION_FOUND:
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

Map map = new HashMap();
map.put("name", device.getName()); //device.getName() : 블루투스 디바이스의 이름
map.put("address", device.getAddress()); //device.getAddress() : 블루투스 디바이스의 MAC 주소
dataDevice.add(map);
adapterDevice.notifyDataSetChanged();
break;
case BluetoothAdapter.ACTION_DISCOVERY_FINISHED:
Toast.makeText(getApplicationContext(), "블루투스 검색 종료", Toast.LENGTH_SHORT).show();
//bt_new = dataDevice;
break;
}
}
};

연제 breaodcastreceiver를 이렇게 사용하고 있는데

listview를 통해 adpaterdevice 를 출력하면 새로운 기기목록이 잘뜨는데


이때 기기목록에서 연결하고싶은 기기를 누르면 해당 기기를 연결할려고 하는데 이부분을 어떻게 해야될지 모르겠네요


Set<BluetoothDevice> bt = bluetoothAdapter.getBondedDevices();
String[] strings = new String[bt.size()];
bt_paired = new BluetoothDevice[bt.size()];
dataPaired.clear();
int index = 0;

if(bt.size() > 0) {
for(BluetoothDevice device : bt) {
bt_paired[index] = device;
strings[index] = device.getName();
index++;

Map map = new HashMap();
map.put("name", device.getName());
map.put("address", device.getAddress());
dataPaired.add(map);
}
adapterPaired.notifyDataSetChanged();
}

이거는 페어링된 리스트 찾기인데

bt_paired같이 bluetoothdevice 형태로 저장하고 싶은데 어떻게 해야될까요??