Selecting Remote Bluetooth Devices for CommunicationsThe BluetoothSock dịch - Selecting Remote Bluetooth Devices for CommunicationsThe BluetoothSock Việt làm thế nào để nói

Selecting Remote Bluetooth Devices

Selecting Remote Bluetooth Devices for Communications
The BluetoothSocket class can be used on the client device to initiate a communications channel from within your application to a listening Bluetooth Server Socket. It is also returned by the Bluetooth Server Socket Listener after a connection to a client device has been established.
Create a client-side Bluetooth Socket by calling createRfcommSocketToServiceRecord on a BluetoothDevice object that represents the target remote server device. The target device should have a Bluetooth Server Socket listening for connection requests (as described in the previous section).
There are a number of ways to obtain a reference to a remote Bluetooth Device, and some important caveats regarding the devices with which you can create a communications link.
Bluetooth Device Connection Requirements
In order for a Bluetooth Socket to establish a connection to a remote Bluetooth Device, the following conditions must be true:
► The remote device must be discoverable.
► The remote device must be accepting connections through a Bluetooth Server Socket.
► The local and remote devices must be paired (bonded). If the devices are not paired, the users of each device will be prompted to pair them when the connection request is initiated.
Finding a Bluetooth Device to Connect To
Bluetooth Device objects are used to represents remote devices. You can query them for the properties of each remote device, and to initiate Bluetooth Socket connections.
There are several ways for you to obtain BluetoothDevices in code. In each case you should check to ensure that the device you intend to connect to is discoverable and (optionally) determine whether you are bonded to it. If you can’t discover the remote device, you should prompt the user to enable discoverability on it.
You learned one technique for finding discoverable Bluetooth Devices earlier in this section. Using the startDiscovery method and monitoring action_found broadcasts allows you to receive Broadcast Intents that include a BluetoothDevice.EXTRA_DEViCE extra containing the discovered Bluetooth Device.
You can also use the getRemoteDevice method on your local Bluetooth Adapter, specifying the hardware address of the remote Bluetooth Device you want to connect to:
BluetoothDevice device = bluetooth.getRemoteDevice("01:23:77:35:2F:AA");
This is particularly useful when you know the hardware address of the target device, such as when using a technology such as Android Beam to share this information between devices.
To find the set of currently paired devices, call getBondedDevices on the local Bluetooth Adapter. You can query the returned set to find out if the target Bluetooth Device is already paired with the local Bluetooth Adapter.
final BluetoothDevice knownDevice =
bluetooth.getRemoteDevice("01:23:77:35:2F:AA");
Set bondedDevices = bluetooth.getBondedDevices();
if (bondedDevices.contains(knownDevice))
// TODO Target device is bonded / paired with the local device.
Opening a Client Bluetooth Socket Connection
To initiate a communications channel to a remote device, create a Bluetooth Socket using the BluetoothDevice object that represents it.
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Selecting Remote Bluetooth Devices for CommunicationsThe BluetoothSocket class can be used on the client device to initiate a communications channel from within your application to a listening Bluetooth Server Socket. It is also returned by the Bluetooth Server Socket Listener after a connection to a client device has been established.Create a client-side Bluetooth Socket by calling createRfcommSocketToServiceRecord on a BluetoothDevice object that represents the target remote server device. The target device should have a Bluetooth Server Socket listening for connection requests (as described in the previous section).There are a number of ways to obtain a reference to a remote Bluetooth Device, and some important caveats regarding the devices with which you can create a communications link. Bluetooth Device Connection RequirementsIn order for a Bluetooth Socket to establish a connection to a remote Bluetooth Device, the following conditions must be true:► The remote device must be discoverable.► The remote device must be accepting connections through a Bluetooth Server Socket.► The local and remote devices must be paired (bonded). If the devices are not paired, the users of each device will be prompted to pair them when the connection request is initiated.Finding a Bluetooth Device to Connect ToBluetooth Device objects are used to represents remote devices. You can query them for the properties of each remote device, and to initiate Bluetooth Socket connections.There are several ways for you to obtain BluetoothDevices in code. In each case you should check to ensure that the device you intend to connect to is discoverable and (optionally) determine whether you are bonded to it. If you can’t discover the remote device, you should prompt the user to enable discoverability on it.You learned one technique for finding discoverable Bluetooth Devices earlier in this section. Using the startDiscovery method and monitoring action_found broadcasts allows you to receive Broadcast Intents that include a BluetoothDevice.EXTRA_DEViCE extra containing the discovered Bluetooth Device.You can also use the getRemoteDevice method on your local Bluetooth Adapter, specifying the hardware address of the remote Bluetooth Device you want to connect to:BluetoothDevice device = bluetooth.getRemoteDevice("01:23:77:35:2F:AA");This is particularly useful when you know the hardware address of the target device, such as when using a technology such as Android Beam to share this information between devices.To find the set of currently paired devices, call getBondedDevices on the local Bluetooth Adapter. You can query the returned set to find out if the target Bluetooth Device is already paired with the local Bluetooth Adapter.final BluetoothDevice knownDevice =bluetooth.getRemoteDevice("01:23:77:35:2F:AA");Set bondedDevices = bluetooth.getBondedDevices();if (bondedDevices.contains(knownDevice))// TODO Target device is bonded / paired with the local device.Opening a Client Bluetooth Socket ConnectionTo initiate a communications channel to a remote device, create a Bluetooth Socket using the BluetoothDevice object that represents it.
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Chọn thiết bị Bluetooth từ xa cho Communications
lớp Các BluetoothSocket có thể được sử dụng trên các thiết bị của khách hàng để bắt đầu một kênh thông tin liên lạc từ bên trong ứng dụng của bạn đến một máy chủ nghe Bluetooth Socket. Nó cũng được trả về bởi Bluetooth server socket Listener sau khi kết nối với một thiết bị của khách hàng đã được thành lập.
Tạo một khách hàng phía Bluetooth socket bằng cách gọi createRfcommSocketToServiceRecord trên một đối tượng BluetoothDevice đại diện các mục tiêu thiết bị máy chủ từ xa. Các thiết bị mục tiêu nên có một Bluetooth server socket lắng nghe các yêu cầu kết nối (như mô tả trong phần trước).
Có một số cách để có được một tham chiếu đến một thiết bị Bluetooth từ xa, và một số cảnh báo quan trọng liên quan đến các thiết bị mà bạn có thể tạo ra . một liên kết truyền thông
Yêu cầu thiết bị Bluetooth kết nối
để cho một socket Bluetooth để thiết lập một kết nối đến một thiết bị Bluetooth từ xa, các điều kiện sau đây phải đúng:
. ► các thiết bị từ xa phải được phát hiện
► các thiết bị từ xa phải được chấp nhận kết nối qua Bluetooth máy chủ socket.
► Các thiết bị địa phương và từ xa phải được ghép nối (ngoại quan). Nếu các thiết bị không được kết nối, người sử dụng của từng thiết bị sẽ được nhắc nhở để ghép chúng khi các yêu cầu kết nối được bắt đầu.
Việc tìm kiếm một thiết bị Bluetooth để kết nối Để
đối tượng thiết bị Bluetooth được sử dụng để đại diện cho các thiết bị từ xa. Bạn có thể truy vấn họ cho các thuộc tính của từng thiết bị từ xa, và để bắt đầu kết nối Bluetooth Socket.
Có một số cách để bạn có được BluetoothDevices trong mã. Trong mỗi trường hợp, bạn nên kiểm tra để đảm bảo rằng thiết bị bạn có ý định để kết nối là có thể phát hiện và (tùy chọn) xác định xem bạn đang liên kết với nó. Nếu bạn không thể khám phá các thiết bị từ xa, bạn nên nhắc nhở người dùng để kích hoạt khả năng khám phá về nó.
Bạn đã học được một kỹ thuật cho việc tìm kiếm phát hiện các thiết bị Bluetooth trước đó trong phần này. Sử dụng phương pháp startDiscovery và giám sát các chương trình phát sóng action_found cho phép bạn nhận Broadcast Intents bao gồm một BluetoothDevice.EXTRA_DEViCE phụ có chứa các thiết bị Bluetooth phát hiện ra.
Bạn cũng có thể sử dụng phương pháp getRemoteDevice trên adapter Bluetooth cục bộ của bạn, xác định địa chỉ phần cứng của thiết bị Bluetooth từ xa bạn muốn kết nối:
thiết bị BluetoothDevice = bluetooth.getRemoteDevice ( "01: 23: 77: 35: 2F: AA");
Điều này đặc biệt hữu ích khi bạn biết địa chỉ phần cứng của thiết bị mục tiêu, chẳng hạn như khi sử dụng một công nghệ như Android beam để chia sẻ thông tin giữa các thiết bị.
để tìm tập hợp các thiết bị hiện đang kết nối, gọi getBondedDevices trên adapter Bluetooth cục bộ. Bạn có thể truy vấn trả về thiết lập để tìm hiểu xem các thiết bị mục tiêu Bluetooth đã ghép nối với các adapter Bluetooth cục bộ.
Thức BluetoothDevice knownDevice =
bluetooth.getRemoteDevice ( "01: 23: 77: 35: 2F: AA");
SetbondedDevices = bluetooth.getBondedDevices ();
if (bondedDevices.contains (knownDevice))
// TODO thiết bị mục tiêu được ngoại quan / ghép nối với các thiết bị cục bộ.
Mở một khách hàng Bluetooth Ổ cắm kết nối
Để khởi tạo một kênh thông tin liên lạc đến một thiết bị từ xa, tạo ra một Bluetooth socket sử dụng các đối tượng BluetoothDevice đại diện cho nó.
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2024 I Love Translation. All reserved.

E-mail: