android 红外
- - 移动开发 - ITeye博客1.初始化manager:. 2.检测设备是否有红外装置:. 已有 0 人发表留言,猛击->> 这里<<-参与讨论. —软件人才免语言低担保 赴美带薪读研.
1.初始化manager:
private void initial() { // TODO Auto-generated method stub manager = (ConsumerIrManager) getSystemService(CONSUMER_IR_SERVICE); }
2.检测设备是否有红外装置:
if (mIrManager != null) { //Check whether the device has an infrared emitter. if (mIrManager.hasIrEmitter()) { //do something //Query the infrared transmitter's supported carrier frequencies CarrierFrequencyRange[] frequencyRanges = mIrManager.getCarrierFrequencies(); if (frequencyRanges != null) { for (CarrierFrequencyRange frequency : frequencyRanges) { frequencyRange += String.format("%1$d ~ %2$d \n", frequency.getMinFrequency(), frequency.getMaxFrequency()); //do something } } } }
3.transmit
//This method is synchronous; when it returns the pattern has been transmitted. Only patterns shorter than 2 seconds will be transmitted. manager.transmit(frequency, pattern);