Quantcast
Channel: IT社区推荐资讯 - ITIndex.net
Viewing all articles
Browse latest Browse all 11804

android 红外

$
0
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);

 

 



已有 0人发表留言,猛击->> 这里<<-参与讨论


ITeye推荐




Viewing all articles
Browse latest Browse all 11804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>