使蓝牙可被发现

时间:2012-02-14 05:03:31

标签: android

我想让蓝牙可以发现,有什么方法可以让我的应用程序执行此操作吗?

我找到了这个链接,但我不知道怎么办。

[http://developer.android.com/reference/android/provider/Settings.System.html#BLUETOOTH_DISCOVERABILITY][1]

1 个答案:

答案 0 :(得分:3)

通过此代码,您的设备可以被发现300秒

 if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
        startActivity(discoverableIntent);
    }
相关问题