这是我的第一篇文章,如果我做了一些愚蠢的事情,请让我知道。这个问题看起来可能与其他帖子相似,但与我看到的其他帖子或多或少相反。
关于项目的事情:
关于项目的事情:
- 我正在开发一个运行在Android 4.0-4.4上的应用程序。
- 我正在使用蓝牙。
- 我正在测试一个运行Android 4.2的物理设备(Eken Necnon)。
- 该设备没有蓝牙硬件。
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) { // This does not ever return true.
Log.w("Bluetooth", "Initializing bluetooth device failed: Bluetooth not supported.");
return;
}
if (!mBluetoothAdapter.isEnabled()) {
mBluetoothAdapter.enable();
}
while (mBluetoothAdapter.getState() != BluetoothAdapter.STATE_ON) {
try {
Log.d(TAG, "Waiting for bluetooth adapter to turn on, taking nap.");
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}