admin 管理员组

文章数量: 1086019


2024年3月26日发(作者:通达oa2017版官方下载)

;

ption;

;

or;

;

;

ty;

ssDialog;

othAdapter;

othDevice;

othSocket;

astReceiver;

t;

;

Filter;

;

r;

e;

publicclassOtherextendsActivity {

publicstaticfinalUUID MyUUID = UUID

.fromString("00001101-0000-1000-8000-00805F9B34FB");

privateBluetoothSocket btSocket =null;

privateBluetoothAdapter adapter =

aultAdapter();// 获取蓝牙设备

privateSet devices =null;

privateBluetoothDevice device;

privateBluetoothDevice btDev;

privateProgressDialog bluetoothPro;

privatebooleanbluetoothstause =true;

privateIntent recalled;

privateconnectbluetooth connectdevice =null;

privatevolatileboolean_discoveryFinished;

privatediscover myDiscovery =newdiscover();

publicvoidonCreate(Bundle savedInstanceState) {

te(savedInstanceState);

setContentView();

// 获取当前已经配对的设备

devices = dedDevices();

// 创建一个进度条

bluetoothPro =newProgressDialog(this);

// 如果已配对的设备大于0 就查找到目标设备并且开始连接 如果没有找到到

设备就开始搜索

if(() >0) {

intcnt =0;

for(Iterator it = or(); it

.hasNext();) {

device = (BluetoothDevice) ();

if(e().equals("PC-60NW")) {

cnt++;

bluetoothConnect(device);

break;

}

}

if(cnt ==0) {

// 没有以配对设备 开始搜索

n("配对设备中没有找到目标设备 开始搜索");

Discovery();

}

}else{

// 没有以配对设备 开始搜索

n("没有以配对设备 开始搜索");

Discovery();

}

}

// 搜索设备开始的函数

publicvoidDiscovery() {

/* 注册接收器 */

IntentFilter discoveryFilter = new IntentFilter(

_DISCOVERY_FINISHED);

registerReceiver(_discoveryReceiver, discoveryFilter);

IntentFilter foundFilter = new IntentFilter(

_FOUND);

registerReceiver(_foundReceiver, foundFilter);

// 再次去确定蓝牙设备状态

if (!led()) {

();

}

// 设置进度条显示的提示信息

sage("");

();

// 启动线程开始搜索设备


本文标签: 设备 开始 搜索 配对 进度条