1

我想知道用户何时连接了免提配件并且没有阻止通话\短信。是否可以知道它何时通过硬件端口或蓝牙连接?

4

1 回答 1

2

在你的 onCreate 或 onResume 中试试这个。

    BluetoothAdapter myLocalAdapter = BluetoothAdapter.getDefaultAdapter();
    BluetoothDevice garniture;
    Set<BluetoothDevice> connectedDevices = myLocalAdapter.getBondedDevices();
    for (BluetoothDevice device : connectedDevices){
        String name = device.getName();
        //...  check for the name you want
        if( name.equals("whatnameisit"){
             garniture = device
        } 
    }
    if (garniture != null){
        // yay we found it,  lets do our work with the device here 
    }
于 2012-10-26T12:50:55.893 回答