2014-12-22 57 views
0

我正在製造藍牙低功耗心率監護儀。 我已經yoused此代碼,但我有在if (btAdapter != null && !btAdapter.isEnabled()) 錯誤的eror是不明類:btAdapterandroid藍牙低功耗心率監護儀

BluetoothManager btManager = (BluetoothManager)getSystemService(Context.BLUETOOTH_SERVICE); 

BluetoothAdapter btAdapter = btManager.getAdapter(); 

if (btAdapter != null && !btAdapter.isEnabled()) { 
    Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); 
    startActivityForResult(enableIntent,REQUEST_ENABLE_BT); 
} 

回答

2

嘗試使用靜態getDefaultAdapter()方法:

BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();