I am trying to write an android app which is a chat app via BLE.
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
I got that message in log cat and not trigger onLeScan()
method while scanning device.
D/BluetoothAdapter: startLeScan(): null
D/BluetoothAdapter:onClientRegistered() - status=0 clientIf=5
D/BluetoothAdapter: stopLeScan()
My code for scanning device is
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() {
Toast.makeText(MainActivity.this, device.getName(), Toast.LENGTH_SHORT)
.show();
}
});
}
};
private void scanLeDevice(final boolean enable) {
if (enable) {
// Stops scanning after a pre-defined scan period.
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mScanning = false;
mBluetoothAdapter.stopLeScan(mLeScanCallback);
invalidateOptionsMenu();
}
}, SCAN_PERIOD);
mScanning = true;
mBluetoothAdapter.startLeScan(mLeScanCallback);
} else {
mScanning = false;
mBluetoothAdapter.stopLeScan(mLeScanCallback);
}
}
when I check my devices specification, they support only buletooth smart, not peripheral mode. My question is that Is it possible to connect BLE supported moblie phone each other without peripheral mode supported? Or is my code just something wrong ?
Edit
I have 3 test devices which are Huawei 730 with android 4.3, Samsung galaxy core 2 with android 4.4.2 and Android one with android 6.0.1. My problem occurred to all of them. I also test with BLEScanner but not detect all my devices. Additionally, I can't detect all my device by running BluetoothLeGatt which is sample project from android sdk.