Bluetooth 蓝牙低能耗应用程序在Nexus上运行,但与其他应用程序不兼容
我正在为连接设备Nordic BLE编写一个应用程序 我使用了加速器蓝牙样本蓝牙信号 该应用程序可以在LG NEXUS 5上很好地检测到我的对象,但在我的另一台Acer Liquid Z200和Wiko GOA上都检测不到 这些手机通常支持蓝牙 提前感谢你的帮助 尼古拉斯 下面是代码的粘贴:Bluetooth 蓝牙低能耗应用程序在Nexus上运行,但与其他应用程序不兼容,bluetooth,bluetooth-lowenergy,Bluetooth,Bluetooth Lowenergy,我正在为连接设备Nordic BLE编写一个应用程序 我使用了加速器蓝牙样本蓝牙信号 该应用程序可以在LG NEXUS 5上很好地检测到我的对象,但在我的另一台Acer Liquid Z200和Wiko GOA上都检测不到 这些手机通常支持蓝牙 提前感谢你的帮助 尼古拉斯 下面是代码的粘贴: public class MainActivity extends Activity { private BluetoothAdapter mBluetoothAdapter = null;
public class MainActivity extends Activity {
private BluetoothAdapter mBluetoothAdapter = null;
private boolean mScanning = false;
private Handler mHandler = new Handler();
private ListAdapter mLeDeviceListAdapter;
private static final long SCAN_TIMEOUT = 5000;
static class ViewHolder {
public TextView text;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("debug", ".");
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.activity_main);
// Initializes Bluetooth adapter.
final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = bluetoothManager.getAdapter();
mLeDeviceListAdapter = new ListAdapter();
((ListView) this.findViewById(R.id.deviceList))
.setAdapter(mLeDeviceListAdapter);
}
public void onScan(View view) {
// check bluetooth is available on on
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(
BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivity(enableBtIntent);
return;
}
scanLeDevice(!mScanning);
}
private void setScanState(boolean value) {
mScanning = value;
setProgressBarIndeterminateVisibility(value);
((Button) this.findViewById(R.id.scanButton)).setText(value ? "Stop"
: "Scan");
}
private void scanLeDevice(final boolean enable) {
if (enable) {
// scan for SCAN_TIMEOUT
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
setScanState(false);
mBluetoothAdapter.stopLeScan(mLeScanCallback);
}
}, SCAN_TIMEOUT);
setScanState(true);
mLeDeviceListAdapter.clear();
mLeDeviceListAdapter.notifyDataSetChanged();
UUID[] uuids = new UUID[1];
uuids[0] = UUID.fromString("6E400001-B5A3-F393-E0A9-E50E24DCCA9K");
mBluetoothAdapter.startLeScan( uuids, mLeScanCallback);
} else {
setScanState(false);
mBluetoothAdapter.stopLeScan(mLeScanCallback);
}
}
// Device scan callback.
private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(final BluetoothDevice device, int rssi,
byte[] scanRecord) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d("debug", "device found");//DOES NOT APPEND ON ACER AND WIKO
}
});
}
};
当它失效时会发生什么?日志里有什么吗?你试着做什么来调试它?日志中没有任何内容。没有附加任何内容。我尝试了一个蓝牙应用程序,但效果很好。看起来只有nexus能够检测到它,而蓝牙设备的官方应用程序找到了我的设备。