大家好,
我想通过程序启用/禁用蓝牙..我有以下代码.
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
Run Code Online (Sandbox Code Playgroud)
但是这种代码在SDK 1.5中不起作用.我怎么能在SDK 1.5中做同样的事情.
我正在尝试使用Android 2.0.1 SDK启用蓝牙功能,我正在使用以下文档中的一些代码:http://developer.android.com/guide/topics/wireless/bluetooth.html
这是:
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
Run Code Online (Sandbox Code Playgroud)
我在REQUEST_ENABLE_BT部分遇到错误,Eclipse说它无法解析.我究竟做错了什么?
如何在android中使用Java显示蓝牙设备名称?我可以参考的任何代码?