当前位置:   article > 正文

android 蓝牙状态,如何在android中显示蓝牙连接状态

android 刷新蓝牙链接状态

我正在开发一个应用程序.我需要显示设备是否已连接到另一个配对设备的状态.我能够显示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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/866529
推荐阅读
相关标签
  

闽ICP备14008679号