개발자 문서를 확인하는 경우 here 링크를 클릭하십시오. 다음과 같은 경우 null 객체가 반환됩니다.
Bluetooth LE 광고 작업을위한 BluetoothLeAdvertiser 객체를 반환합니다. Bluetooth가 꺼져 있거나 Bluetooth LE Advertising이이 장치에서 지원되지 않는 경우 null을 반환합니다. 당신이 전혀 장치가 블루투스를 지원하는지 여부를 알 수없는 경우 먼저 지원되는 경우 시스템에 의해 반환 된 BluetoothAdapter
이 null
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
}
그런 다음 그들이 볼 isMultipleAdvertisementSupported()
전화를 조언하는 경우
당신은 확인해야합니다 .
if(!mBluetoothAdapter.isMultipleAdvertisementSupported()){
//Device does not support Bluetooth LE
}
BLE를 지원하는 경우 Bluetooth가 활성화되어 있는지 확인하고 그렇지 않은 경우 사용자가이를 인식하고 해결하도록해야합니다.
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
당신은 스캔을 시작하기 전에 어댑터가 mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()
에 대한 null
이 관련이있을 수 : http://stackoverflow.com/questions/26441785/ does-bluetoothleadvertiser-work-on-a-nexus-5-with-android-5-0 – Nfear
장치가 Bluetooth LE 주변 장치 모드를 지원하지 않을 수 있습니다. 여기 [지원되는 모델에 대한 토론] (http://stackoverflow.com/questions/26482611/chipsets-devices-supporting-android-5ble-peripheral-mode)과 [이 페이지] (https : // altbeacon .github.io/android-beacon-library/beacon-transmitter-devices.html)은 아마도 그러한 정보를 얻는 가장 좋은 소스 일 것입니다. –
와우, 오케이 .- 고마워. 다음 안드로이드 장치에서 블루투스 신호를 방송하는 다른 방법이 있습니까? – Anfaje