我想知道遠程物理設備中的事件在監聽設備中觸發ACTION_ACL_CONNECTED和ACTION_ACL_DISCONNECTED。我的測試結果沒有意義。我已經收集對方的幾個分米內的幾個設備:觸發BluetoothDevice.ACTION_ACL廣播的是什麼?
一個的Galaxy Tab P7500運行的是Android 3.1
一個I5500手機運行的是Android 2.2
一臺PC的winXP與藍牙USB加密狗
兩個帶開/關按鈕的耳機
首先,我手動配對Tab中的所有設備。 PC和手機都不能與任何其他設備配對,但Tab。 (其中一個耳機無法以任何方式被標籤找到,但可以通過手機和編程方式輕鬆找到)。然後我有一個簡單的應用程序來啓動發現,並偵聽並顯示ACL廣播。這是發生了什麼(每次同樣的事情後,在其瘋狂一致):啓用所有設備從標籤
- startDiscovery(): - PC是唯一的設備發現
- 禁用藍牙PC: - 上的Tab
沒有反應在電腦上啓用藍牙: - 對耳機一日一次Tab鍵
電源無反應: - ACTION_ACL_CONNECTED上的Tab
- 關機耳機: - 無反應Ø ñ再次對耳機的標籤
電源: - ACTION_ACL_DISCONNECTED和 ACTION_ACL_CONNECTED快速連續上的Tab
禁用藍牙選項卡: - 在標籤
沒有反應在標籤上啓用藍牙: - 耳機ACTION_ACL_CONNECTED上的Tab
startDiscovery()的電話: - PC是由 手機發現的唯一設備,雖然手機只與標籤配對,不與 臺PC。否則,手機僅對耳機不起反應。
這個爛攤子怎麼辦?即使配對並在範圍內上電,也不能依賴引發ACTION_ACL_CONNECT的設備嗎?
下面是廣播接收器和活動的onCreate的方法,但我不希望在此代碼的細節無關緊要:
BroadcastReceiver intentReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (device != null) {
name = device.getName();
Log.v(TAG, "Device=" + device.getName());
}
else {
name = "None";
}
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
text1.setText(name + " connected " + (checkCounter++));
Log.v(TAG, "connected: " + device);
}
else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) {
text2.setText(name + " disconnected " + (checkCounter++));
Log.v(TAG, "disconnected: " + device);
}
else if (BluetoothDevice.ACTION_FOUND.equals(action)) {
text3.setText(name + " found " + (checkCounter++));
Log.v(TAG, "found: " + device + "");
}
else if (blueAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
text4.setText("Started " + (checkCounter++));
Log.v(TAG, "Discovery started");
}
else if (blueAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
text4.setText("Finished " + (checkCounter++));
Log.v(TAG, "Discovery finished");
}
}
};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bluetoothlayout);
text1 = (TextView)findViewById(R.id.textView1);
text2 = (TextView)findViewById(R.id.textView2);
text3 = (TextView)findViewById(R.id.textView3);
text4 = (TextView)findViewById(R.id.textView4);
BluetoothDevice mw600 = blueAdapter.getRemoteDevice("58:17:0C:EB:C5:08");
BluetoothDevice bt500 = blueAdapter.getRemoteDevice("00:1D:43:00:C4:54");
BluetoothDevice galaxyTab = blueAdapter.getRemoteDevice("00:07:AB:6A:96:7D");
BluetoothDevice pcDongle = blueAdapter.getRemoteDevice("00:15:83:4D:8B:57");
intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
intentFilter.addAction(blueAdapter.ACTION_DISCOVERY_STARTED);
intentFilter.addAction(blueAdapter.ACTION_DISCOVERY_FINISHED);
if (!isReceiverRegistered) {
registerReceiver(intentReceiver, intentFilter);
isReceiverRegistered = true;
}
if (!blueAdapter.isEnabled()) {
blueAdapter.enable();
}
blueAdapter.startDiscovery();
}
agrre和你在一起。可能是10秒連接之後,收到diconnect廣播 – 2013-11-09 23:46:26