2016-06-21 3 views
0
BluetoothLeAdvertiser advertiser = BluetoothAdapter.getDefaultAdapter().getBluetoothLeAdvertiser(); 

이 값은 null을 반환합니다. API 21과 API 23에서 시도했지만 동일한 결과가 있습니다. 내가 뭘 놓치고 있는지 모르겠다.getBluetoothLeAdvertiser()는 null을 반환합니다.

앱이 제대로 빌드되고 실행되기 때문에 물론 광고주가 사용되어 앱이 다운 될 때까지 계속 실행됩니다.

제공되는 도움말에 감사드립니다. :)

+0

이 관련이있을 수 : http://stackoverflow.com/questions/26441785/ does-bluetoothleadvertiser-work-on-a-nexus-5-with-android-5-0 – Nfear

+0

장치가 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)은 아마도 그러한 정보를 얻는 가장 좋은 소스 일 것입니다. –

+0

와우, 오케이 .- 고마워. 다음 안드로이드 장치에서 블루투스 신호를 방송하는 다른 방법이 있습니까? – Anfaje

답변

4

개발자 문서를 확인하는 경우 here 링크를 클릭하십시오. 다음과 같은 경우 null 객체가 반환됩니다.

Bluetooth LE 광고 작업을위한 BluetoothLeAdvertiser 객체를 반환합니다. Bluetooth가 꺼져 있거나 Bluetooth LE Advertising이이 장치에서 지원되지 않는 경우 null을 반환합니다. 당신이 전혀 장치가 블루투스를 지원하는지 여부를 알 수없는 경우 먼저 지원되는 경우 시스템에 의해 반환 된 BluetoothAdapternull

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

0

체크 인 시간의 대부분을 커버해야 그

관련 문제