【发布时间】:2015-12-06 11:50:47
【问题描述】:
我如何知道设备在安卓中是否有红外线硬件?
我想在此基础上做一些事情。我尝试使用类似下面的东西,但没有运气。
this.getPackageManager().hasSystemFeature( .. various constants ..)
【问题讨论】:
我如何知道设备在安卓中是否有红外线硬件?
我想在此基础上做一些事情。我尝试使用类似下面的东西,但没有运气。
this.getPackageManager().hasSystemFeature( .. various constants ..)
【问题讨论】:
尝试以下代码
科特林:
val irManager: ConsumerIrManager = getSystemService(CONSUMER_IR_SERVICE) as ConsumerIrManager
// Check whether IrEmitter is available on the device.
if (irManager.hasIrEmitter()) {
Log.i("IR_Testing", "found IR Emitter")
}else{
Log.i("IR_Testing", "Cannot found IR Emitter on the device")
}
Java:
private ConsumerIrManager irManager ;
irManager = (ConsumerIrManager) getSystemService(CONSUMER_IR_SERVICE);
if (irManager.hasIrEmitter()) {
Log.i("IR_Testing", "found IR Emitter");
} else {
Log.i("IR_Testing", "Cannot found IR Emitter on the device");
}
【讨论】: