2つの銀河を隣り合わせで使用している場合でも、このコードが常に1つのBluetoothデバイスのみを返す理由を誰かが説明できますか?このコードはSamsungGalaxyTabで実行されており、SamsungGalaxyGioの両方を適切なBluetoothアクティベーションでテストするために使用しています。デフォルトの調査を確認すると、機能しますが、このコードでは機能しません。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
out = new TextView(this);
setContentView(out);
// Getting the Bluetooth adapter
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
out.append("\nAdapter: " + adapter);
// Check for Bluetooth support in the first place
// Emulator doesn't support Bluetooth and will return null
if (adapter == null) {
out.append("\nBluetooth NOT supported. Aborting.");
return;
}
// Starting the device discovery
out.append("\nStarting discovery...");
adapter.startDiscovery();
out.append("\nDone with discovery...");
// Listing paired devices out.append("\nDevices Paired:");
Set<BluetoothDevice> devices = adapter.getBondedDevices();
for (BluetoothDevice device : devices) {
out.append("\nFound device: " + device);
}
}