赞
踩
我正在开发一个应用程序.我需要显示设备是否已连接到另一个配对设备的状态.我能够显示Toast消息,但无法在List视图中显示蓝牙是否连接到其他设备.
你能否请一次查看我添加的代码并帮助我解决问题..
我的DeviceListActivity.class
mListView = (ListView) findViewById(R.id.lv_paired);
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Set pairedDevices = mBluetoothAdapter.getBondedDevices();
mDeviceList = new ArrayList();
mDeviceList.addAll(pairedDevices);
mAdapter = new DeviceListAdapter(this);
mAdapter.setData(mDeviceList);
mAdapter.setListener(new OnConnectButtonClickListener() {
public void onConnectButtonClick(int position) {
BluetoothDevice device = mDeviceList.get(position);
ConnectDevice(device);
}
});
mListView.setAdapter(mAdapter);
registerReceiver(mConnectReceiver, new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
r
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。