リモート物理デバイスのどのイベントが、リスニングデバイスでACTION_ACL_CONNECTEDおよびACTION_ACL_DISCONNECTEDをトリガーするかを知りたいと思います。私のテスト結果は意味をなさない。私は、互いに数デシメートルの範囲内のいくつかのデバイスを集めています実行しているアンドロイド3.1BluetoothDevice.ACTION_ACLブロードキャストをトリガーする要因は何ですか?
i5500の携帯電話を実行している
ギャラクシータブP7500のAndroid 2.2
のBluetooth USBドングル
とPCのWinXPのオン/オフボタン付きの2つのヘッドセット
まず、タブからすべてのデバイスと手動でペアリングします。 PCと携帯電話のどちらも、Tab以外の他のデバイスとペア設定されていません。 (ヘッドセットの1つは、タブによって決して見つけることはできませんが、手動でもプログラムでも電話から簡単に見つけることができます)。次に、私は発見を始めるための簡単なアプリがあり、ACLブロードキャストを聞いて表示します。すべてのデバイスを有効にしてタブから
- StartDiscoveryを():そして、これは(同じことを毎回、その狂気での一貫したを)何が起こるかである - PCが唯一のデバイスは、PC上で
- 無効にブルートゥースを見つけたです。 - タブ
に何も反応がPCのBluetoothを有効にしない: - ヘッドセット1回目のタブ
パワーに何も反応: - タブ
- 電源オフヘッドセットにACTION_ACL_CONNECTED: - いいえ、反応Oを再びヘッドセットのn個のタブ
パワー: - タブに立て続けにACTION_ACL_DISCONNECTEDと ACTION_ACL_CONNECTED
タブで無効にブルートゥース: -
- タブに何も反応がタブでBluetoothを有効にしません: - 携帯電話からのタブ
StartDiscoveryを上のヘッドセットACTION_ACL_CONNECTEDは(): - 電話だけではないと、タブと対になっているが、PCは、 電話で見つかった唯一のデバイスであります210 PC。そうでない場合、電話機は、 タブに反応しないヘッドセットにのみ反応します。
この混乱から何を作るのですか? ACTION_ACL_CONNECTがペアになっていても範囲内でパワーアップしても、そのデバイスに依存することはできませんか?ここで
はBroadcastReceiverと活動の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();
}
あなたと一緒にいる10秒後に接続すると、ブロードキャストが受信されます –