我想测试我的Android设备是否可被发现,然后发送提示用户打开它的意图,我该怎么办?
意图如下:
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 30);
startActivityForResult(intent, idBlueToothDiscoveryRequest);
答案 0 :(得分:10)
我发现了:
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);
}