当应用程序安装在移动设备上并尝试获取其他移动设备电池信息时,如何将移动设备与BLE
进行通信,其中ScanCallback不会返回有关搜索BLE device
的任何信息。
private ScanCallback scanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
// super.onScanResult(callbackType, result);
Log.e("scaning result"," :"+result.getDevice().getName());
bluetoothDevice = result.getDevice();
deviceAddress.setText(bluetoothDevice.getAddress());
deviceName.setText(bluetoothDevice.getName());
progressBar.setVisibility(View.INVISIBLE);
}
@Override
public void onBatchScanResults(List<ScanResult> results) {
super.onBatchScanResults(results);
}
@Override
public void onScanFailed(int errorCode) {
super.onScanFailed(errorCode);
Log.d(TAG, "Scanning Failed " + errorCode);
progressBar.setVisibility(View.INVISIBLE);
}
};