Alternatively, you can monitor changes in discoverability by receiving dịch - Alternatively, you can monitor changes in discoverability by receiving Việt làm thế nào để nói

Alternatively, you can monitor chan

Alternatively, you can monitor changes in discoverability by receiving the action_scan_mode_changed broadcast action. The Broadcast Intent includes the current and previous scan modes as extras:
registerReceiver(new BroadcastReceiver() {
©Override
public void onReceive(Context context, Intent intent) {
String prevScanMode = BluetoothAdapter.EXTRA_PREVI0US_SCAN_M0DE;
String scanMode = BluetoothAdapter.EXTRA_SCAN_M0DE;
int currentScanMode = intent.getIntExtra(scanMode, -1); int prevMode = intent.getIntExtra(prevScanMode, -1);
Log.d(TAG, "Scan Mode: " + currentScanMode +
". Previous: " + prevMode);
}
},
new IntentFilter(BluetoothAdapter.ACTI0N_SCAN_M0DE_CHANGED));
Discovering Remote Devices
In this section you’ll learn how to initiate discovery from your local Bluetooth Adapter to find discoverable devices nearby.
The discovery process can take some time to complete (up to 12 seconds). During this time, performance of your Bluetooth Adapter communications will be seriously degraded. Use the techniques in this section to check and monitor the discovery status of the Bluetooth Adapter, and avoid doing high-bandwidth operations (including connecting to a new remote Bluetooth Device) while discovery is in progress.
You can check if the local Bluetooth Adapter is already performing a discovery scan by using the isDiscovering method.
To initiate the discovery process, call startDiscovery on the Bluetooth Adapter:
if (bluetooth.isEnabled()) bluetooth.startDiscovery();
To cancel a discovery in progress, call cancelDiscovery.
The discovery process is asynchronous. Android uses broadcast Intents to notify you of the start and end of discovery as well as remote devices discovered during the scan.
You can monitor changes in the discovery process by creating Broadcast Receivers to listen for the action_discovery_started and action_discovery_finished Broadcast Intents:
BroadcastReceiver discoveryMonitor = new BroadcastReceiver() {
String dStarted = BluetoothAdapter.ACTI0N_DISC0VERY_STARTED;
String dFinished = BluetoothAdapter.ACTI0N_DISC0VERY_FINISHED;
©Override
public void onReceive(Context context, Intent intent) { if (dStarted.equals(intent.getAction())) {
// Discovery has started.
Log.d(TAG, "Discovery Started...");
}
else if (dFinished.equals(intent.getAction())) {
// Discovery has completed.
Log.d(TAG, "Discovery Complete.");
}
}
};
registerReceiver(discoveryMonitor,
new IntentFilter(dStarted)); registerReceiver(discoveryMonitor,
new IntentFilter(dFinished));
Discovered Bluetooth Devices are returned via Broadcast Intents by means of the action_found broadcast action.
As shown in Listing 16-5, each Broadcast Intent includes the name of the remote device in an extra indexed as BluetoothDevice.EXTRA_NAME, and an immutable representation of the remote Bluetooth device as a BluetoothDevice parcelable object stored under the BluetoothDevice .extra_device extra.
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Ngoài ra, bạn có thể theo dõi những thay đổi trong discoverability bằng cách nhận được action_scan_mode_changed hành động phát sóng. Ý định phát sóng bao gồm các chế độ quét hiện tại và trước đó là tính năng bổ sung:registerReceiver (new BroadcastReceiver() {}© Ghi đèkhu vực void onReceive (Context bối cảnh, Intent intent) {}String prevScanMode = BluetoothAdapter.EXTRA_PREVI0US_SCAN_M0DE;String scanMode = BluetoothAdapter.EXTRA_SCAN_M0DE;int currentScanMode = intent.getIntExtra (scanMode, -1); int prevMode = intent.getIntExtra (prevScanMode, -1);Log.d (từ khóa, "chế độ quét:" + currentScanMode +". Trước: "+ prevMode);}},mới IntentFilter(BluetoothAdapter.ACTI0N_SCAN_M0DE_CHANGED));Khám phá thiết bị từ xaTrong phần này bạn sẽ tìm hiểu làm thế nào để bắt đầu khám phá từ điều hợp Bluetooth địa phương của bạn để tìm các thiết bị phát hiện gần đó.Quá trình khám phá có thể mất một chút thời gian để hoàn thành (lên đến 12 giây). Trong thời gian này, hiệu suất của truyền thông Bluetooth Adapter của bạn sẽ được nghiêm túc suy thoái. Sử dụng các kỹ thuật trong phần này để kiểm tra và giám sát trạng thái phát hiện ra của bộ điều hợp Bluetooth, và tránh làm băng thông cao hoạt động (bao gồm cả kết nối với một thiết bị Bluetooth từ xa) trong khi khám phá tiến hành.Bạn có thể kiểm tra nếu bộ điều hợp Bluetooth địa phương đã thực hiện một quét phát hiện bằng cách sử dụng phương pháp isDiscovering.Để bắt đầu quá trình khám phá, hãy gọi startDiscovery trên bộ điều hợp Bluetooth:if (bluetooth.isEnabled()) bluetooth.startDiscovery();To cancel a discovery in progress, call cancelDiscovery.The discovery process is asynchronous. Android uses broadcast Intents to notify you of the start and end of discovery as well as remote devices discovered during the scan.You can monitor changes in the discovery process by creating Broadcast Receivers to listen for the action_discovery_started and action_discovery_finished Broadcast Intents:BroadcastReceiver discoveryMonitor = new BroadcastReceiver() {String dStarted = BluetoothAdapter.ACTI0N_DISC0VERY_STARTED;String dFinished = BluetoothAdapter.ACTI0N_DISC0VERY_FINISHED;©Overridepublic void onReceive(Context context, Intent intent) { if (dStarted.equals(intent.getAction())) {// Discovery has started.Log.d(TAG, "Discovery Started...");}else if (dFinished.equals(intent.getAction())) {// Discovery has completed.Log.d(TAG, "Discovery Complete.");}}};registerReceiver(discoveryMonitor,new IntentFilter(dStarted)); registerReceiver(discoveryMonitor,new IntentFilter(dFinished));Discovered Bluetooth Devices are returned via Broadcast Intents by means of the action_found broadcast action.As shown in Listing 16-5, each Broadcast Intent includes the name of the remote device in an extra indexed as BluetoothDevice.EXTRA_NAME, and an immutable representation of the remote Bluetooth device as a BluetoothDevice parcelable object stored under the BluetoothDevice .extra_device extra.
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Ngoài ra, bạn có thể theo dõi những thay đổi trong khả năng khám phá bằng cách nhận các hành động phát sóng action_scan_mode_changed. Các Ý định phát sóng bao gồm các chế độ quét hiện tại và trước đây là tính năng bổ sung:
registerReceiver (BroadcastReceiver mới () {
© Override
public void onReceive (bối cảnh bối cảnh, ý định Ý định) {
string prevScanMode = BluetoothAdapter.EXTRA_PREVI0US_SCAN_M0DE;
Chuỗi scanMode = BluetoothAdapter.EXTRA_SCAN_M0DE;
int currentScanMode = intent.getIntExtra (scanMode, -1); int prevMode = intent.getIntExtra (prevScanMode, -1);
Log.d (TAG, "Chế độ quét:" + currentScanMode +
"trước:." + prevMode);
}
},
mới IntentFilter (BluetoothAdapter.ACTI0N_SCAN_M0DE_CHANGED));
Khám phá thiết bị từ xa
. Trong phần này bạn sẽ học cách để bắt đầu khám phá từ adapter Bluetooth cục bộ của bạn để tìm các thiết bị có thể phát hiện gần
quá trình khám phá có thể mất một thời gian để hoàn thành (tối đa 12 giây). Trong thời gian này, hoạt động của truyền thông Bluetooth Adapter của bạn sẽ bị suy thoái nghiêm trọng. Sử dụng các kỹ thuật trong phần này để kiểm tra và theo dõi tình trạng phát hiện Adapter Bluetooth, và tránh làm các hoạt động băng thông cao (bao gồm cả kết nối với một thiết bị Bluetooth từ xa mới) trong khi khám phá được tiến hành.
Bạn có thể kiểm tra nếu Adapter Bluetooth cục bộ là đã thực hiện một khám phá quét bằng cách sử dụng các phương pháp isDiscovering.
Để bắt đầu quá trình phát hiện, gọi startDiscovery trên adapter Bluetooth:
if (bluetooth.isEnabled ()) bluetooth.startDiscovery ();
. Để hủy một khám phá trong tiến trình, gọi cancelDiscovery
Khám phá quá trình là không đồng bộ. Android sử dụng Intents phát sóng để thông báo cho bạn khi bắt đầu và kết thúc của sự khám phá cũng như các thiết bị từ xa phát hiện trong quá trình quét.
Bạn có thể theo dõi những thay đổi trong quá trình khám phá bằng cách tạo ra Broadcast Receivers để lắng nghe cho Intents Broadcast action_discovery_started và action_discovery_finished:
BroadcastReceiver discoveryMonitor = new BroadcastReceiver () {
string dStarted = BluetoothAdapter.ACTI0N_DISC0VERY_STARTED;
Chuỗi dFinished = BluetoothAdapter.ACTI0N_DISC0VERY_FINISHED;
© Override
public void onReceive (bối cảnh bối cảnh, ý định ý định) {if (dStarted.equals (intent.getAction ())) {
// Discovery đã bắt đầu .
Log.d (TAG, "Discovery Bắt đầu ...");
}
else if (dFinished.equals (intent.getAction ())) {
// Discovery đã hoàn thành.
Log.d (TAG, "Discovery hoàn thành.") ;
}
}
};
registerReceiver (discoveryMonitor,
IntentFilter mới (dStarted)); registerReceiver (discoveryMonitor,
IntentFilter mới (dFinished));
. phát hiện các thiết bị Bluetooth được trả về thông qua Broadcast Intents bằng phương tiện của các hành động action_found phát sóng
Như trong Liệt kê 16-5, mỗi ý định phát sóng bao gồm tên của thiết bị từ xa trong một thêm lập chỉ mục như BluetoothDevice.EXTRA_NAME, và một đại diện bất biến của các thiết bị Bluetooth từ xa như một đối tượng parcelable BluetoothDevice được lưu trữ dưới BluetoothDevice .extra_device thêm.
đ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: