15

我想在发送提示用户打开它的意图之前测试我的 android 设备是否可被发现,我该怎么办?

意图如下:

Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 30);
startActivityForResult(intent, idBlueToothDiscoveryRequest);
4

1 回答 1

15

我发现:

if(mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE)
{
    Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
    intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 30);
    startActivityForResult(intent, idBlueToothDiscoveryRequest);
}
于 2014-12-17T02:41:51.397 回答