2016-03-14 97 views
1

我有一個Xperia Z3C,Android 5.1.1,我試圖通過藍牙將它連接到Nexus 4 Android 6.0.1。配對它們是可以的,但是當我嘗試連接它們時,它表示「連接」不到一秒鐘,並自動斷開連接。藍牙在連接到另一個Android設備一段時間後保持斷開連接

這是一個已知的問題?我還沒有發現任何關於這個。

這裏是logcat的說:

03-14 17:25:55.308: E/bt-btif(14245): bte_scan_filt_param_cfg_evt, 1 
03-14 17:25:55.308: E/bt-btif(14245): bte_scan_filt_param_cfg_evt, 1 
03-14 17:25:55.990: E/bt-btm(14245): new address: xx:xx:xx:xx:xx:xx 
03-14 17:25:55.990: E/bt-btm(14245): new address: xx:xx:xx:xx:xx:xx 
03-14 17:25:56.712: E/bt-btm(14245): new address: xx:xx:xx:xx:xx:xx 
03-14 17:25:57.464: E/bt-btif(14245): bte_scan_filt_param_cfg_evt, 1 
03-14 17:25:57.814: E/bt-btm(14245): Ignoring RNR as the state is not BTM_SEC_STATE_GETTING_NAME 
03-14 17:25:57.933: E/NetlinkEvent(318): Unknown ifindex 41 in RTM_DELADDR 
03-14 17:25:57.963: E/dhcpcd(15974): bt-pan: interface not found or invalid 
03-14 17:25:57.986: E/BluetoothPanServiceJni(14245): ## ERROR : disconnectPanNative(L224): Failed disconnect pan channel, status: 1## 
03-14 17:25:58.139: E/BluetoothTetheringNetworkFactory(14245): DHCP request error:DHCP result was failed 
03-14 17:26:01.382: E/bt-btm(14245): btm_sec_disconnected - Clearing Pending flag 
+0

關於藍牙問題和Android 5.x有一個相當冗長和多變的錯誤。它讓很多人對事物進行報告,但沒有獲得關於它有什麼問題的很多有用的信息。 https://code.google.com/p/android/issues/detail?id=79488 –

+0

我發佈了所有的信息,我無法找到發生了什麼。我正在開發一個藍牙打印應用程序,並試圖用模擬Nexus上的BT打印機的應用程序進行測試。我甚至沒有嘗試向它發送數據,因爲藍牙連接失敗,但是當我提出這個問題後,數據發送成功,儘管這兩個設備沒有連接。我不知道這裏發生了什麼。 @RobertNekic –

回答

1

所以兩件事情可以在這裏繼續。您嘗試維持連接的第二臺設備存在維護連接的問題,或者兩者之間存在干擾,導致連接中斷,但時間不夠,無法完全終止連接。

+0

干擾是什麼意思? –

+1

藍牙干擾可能是由以下幾種情況引起的:https://support.apple.com/en-us/HT201542 – Ethan

2

我在嘗試掃描Android應用程序中的藍牙設備時遇到了同樣的問題。有趣的是,它不會拋出任何異常(被捕獲或未被捕獲)並且默默地失敗!對於API級別> = 23(Android 6.0)的設備會發生此問題。這裏是我的logcat日誌的摘錄:

03-30 14:07:52.099 192-211/? I/BufferQueueProducer: [org.manios.testbt/org.manios.testbt.printing.BluetoothPrinterDiscovery](this:0x7fa16de400,id:1467,api:1,p:26262,c:192) queueBuffer: fps=0.19 dur=5154.29 max=5154.29 min=5154.29 
03-30 14:07:52.114 192-192/? I/SurfaceFlinger: [Built-in Screen (type:0)] fps:1.091767,dur:1831.89,max:999.66,min:832.23 
03-30 14:07:52.137 774-1001/? D/InputReader: AP_PROF:AppLaunch_dispatchPtr:Up:89556864, ID:0, Index:2056797440 
03-30 14:07:52.137 774-1001/? I/PerfService: PerfServiceNative_boostEnableTimeoutMsAsync:3, 100 
03-30 14:07:52.138 26262-26262/org.manios.testbt D/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 0 
03-30 14:07:52.138 26262-26262/org.manios.testbt D/BluetoothAdapter: isEnabled 
03-30 14:07:52.140 26262-26262/org.manios.testbt D/BluetoothAdapter: getName 
03-30 14:07:52.141 774-1636/? D/BluetoothManagerService: checkIfCallerIsForegroundUser: valid=true callingUser=0 parentUser=-10000 foregroundUser=0 
03-30 14:07:52.142 21807-21818/? D/BluetoothAdapterProperties: getName: mName = Lenovo TAB3 8 
03-30 14:07:52.144 26262-666/org.manios.testbt D/BluetoothAdapter: isEnabled 
03-30 14:07:52.146 26262-666/org.manios.testbt D/BluetoothAdapter: isDiscovering 
03-30 14:07:52.148 26262-666/org.manios.testbt D/BluetoothAdapter: 109507751: getState(). Returning 12 
03-30 14:07:52.152 21807-21817/? D/BluetoothAdapterProperties: isDiscovering: mDiscovering = false 
03-30 14:07:52.156 26262-666/org.manios.testbt D/BluetoothAdapter: startDiscovery 
03-30 14:07:52.158 26262-666/org.manios.testbt D/BluetoothAdapter: 109507751: getState(). Returning 12 
03-30 14:07:52.160 21807-21830/? W/bt_btif: bta_dm_check_av:0 
03-30 14:07:52.172 21807-21830/? E/bt_btif: bte_scan_filt_param_cfg_evt, 1 
03-30 14:07:52.181 21807-21823/? I/BluetoothAdapterProperties: Callback:discoveryStateChangeCallback with state:1 
03-30 14:07:52.182 774-2924/? V/ActivityManager: Broadcast: Intent { act=android.bluetooth.adapter.action.DISCOVERY_STARTED flg=0x10 } ordered=false userid=0 callerApp=ProcessRecord{c376192 21807:com.android.bluetooth/1002} 
03-30 14:07:52.184 1057-1265/? V/BluetoothEventManager: Received android.bluetooth.adapter.action.DISCOVERY_STARTED 
03-30 14:07:52.185 1057-1265/? D/BluetoothEventManager: scanning state change to true 
03-30 14:07:52.186 21983-21983/? D/ActivityThread: BDC-Calling onReceive: intent=Intent { act=android.bluetooth.adapter.action.DISCOVERY_STARTED flg=0x10 cmp=com.android.settings/.bluetooth.BluetoothDiscoveryReceiver }, rec[email protected]b02fe63 
03-30 14:07:52.186 21983-21983/? V/BluetoothDiscoveryReceiver: Received: android.bluetooth.adapter.action.DISCOVERY_STARTED 
03-30 14:07:52.187 21983-21983/? D/ActivityThread: BDC-RECEIVER handled : 0/ReceiverData{intent=Intent { act=android.bluetooth.adapter.action.DISCOVERY_STARTED flg=0x10 cmp=com.android.settings/.bluetooth.BluetoothDiscoveryReceiver } packageName=com.android.settings resultCode=-1 resultData=null resultExtras=null} 
03-30 14:07:52.218 774-1001/? D/InputReader: AP_PROF:AppLaunch_dispatchPtr:Down:89556946, ID:0, Index:2056794048 
03-30 14:07:52.219 774-1001/? I/PerfService: PerfServiceNative_boostEnableAsync:3 

我以後用這個issue一些搜索發現,在API等級> = 23(在Android 6.0),我們有以下權限添加到AndroidManifext.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 

使掃描和其他藍牙操作正常工作。

在Android文檔中,它在BluetoothAdapter.startDiscovery()中聲明它需要BLUETOOTH_ADMIN權限,但沒有進一步的細節。但是如果我們看一下BluetoothLeScanner.startScan(),它明確指出:

需要BLUETOOTH_ADMIN權限。應用必須擁有ACCESS_COARSE_LOCATIONACCESS_FINE_LOCATION權限才能獲得結果。

希望這會有所幫助!

+1

@IgorGanapolsky我通過指向官方Android文檔的鏈接更新了我的答案。 –