android 蓝牙操作

 

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if(adapter != null)
{
    if(adapter.isEnabled()
    {
         Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
         startActivity(intent);
    }

    set<BluetoothDevice>devices = adapter.getBondedDevices();
    if(devices.size()>0)
    {
         for(Iterator iterator = devices.iterator();iterator.hasNext();)
        {
             BluetoothDevices bluetoothDevice =(BluetoothDevice)iterator.next();
        }
    }

}

posted @ 2011-11-01 12:51  andriod2012  阅读(132)  评论(0编辑  收藏  举报