设备未通过蓝牙低功耗将移动设备连接到设备

时间:2018-04-20 10:53:04

标签: android bluetooth-lowenergy android-ble

当应用程序安装在移动设备上并尝试获取其他移动设备电池信息时,如何将移动设备与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);
         }
     };

0 个答案:

没有答案