掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流

在平川等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站設(shè)計、做網(wǎng)站 網(wǎng)站設(shè)計制作定制網(wǎng)站,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),網(wǎng)絡(luò)營銷推廣,成都外貿(mào)網(wǎng)站制作,平川網(wǎng)站建設(shè)費用合理。
傳統(tǒng)藍牙本機管理主要是針對藍牙本機的基本操作,包括打開和關(guān)閉藍牙、設(shè)置和獲取本機藍牙名稱、掃描和取消掃描周邊藍牙設(shè)備、獲取本機藍牙 profile 對其他設(shè)備的連接狀態(tài)、獲取本機藍牙已配對的藍牙設(shè)備列表。
| 接口名 | 功能描述 |
|---|---|
| getDefaultHost(Context context) | 獲取BluetoothHost實例,去管理本機藍牙操作。 |
| enableBt() | 打開本機藍牙。 |
| disableBt() | 關(guān)閉本機藍牙。 |
| setLocalName(String name) | 設(shè)置本機藍牙名稱。 |
| getLocalName() | 獲取本機藍牙名稱。 |
| getBtState() | 獲取本機藍牙狀態(tài)。 |
| startBtDiscovery() | 發(fā)起藍牙設(shè)備掃描。 |
| cancelBtDiscovery() | 取消藍牙設(shè)備掃描。 |
| isBtDiscovering() | 檢查藍牙是否在掃描設(shè)備中。 |
| getProfileConnState(int profile) | 獲取本機藍牙profile對其他設(shè)備的連接狀態(tài)。 |
| getPairedDevices() | 獲取本機藍牙已配對的藍牙設(shè)備列。 |
// 獲取藍牙本機管理對象
BluetoothHost bluetoothHost = BluetoothHost.getDefaultHost(context);
// 調(diào)用打開接口
bluetoothHost.enableBt();
// 調(diào)用獲取藍牙開關(guān)狀態(tài)接口
int state = bluetoothHost.getBtState(); //開始掃描
mBluetoothHost.startBtDiscovery();
//接收系統(tǒng)廣播
public class MyCommonEventSubscriber extends CommonEventSubscriber {
@Override
public void onReceiveEvent(CommonEventData var){
Intent info = var.getIntent();
if(info == null) return;
//獲取系統(tǒng)廣播的action
String action = info.getAction();
//判斷是否為掃描到設(shè)備的廣播
if(action == BluetoothRemoteDevice.EVENT_DEVICE_DISCOVERED){
IntentParams myParam = info.getParams();
BluetoothRemoteDevice device = (BluetoothRemoteDevice)myParam.getParam(BluetoothRemoteDevice.REMOTE_DEVICE_PARAM_DEVICE);
}
}
} 
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流