Snehal Masne
Snehal Masne

Reputation: 3429

How to check if device has infra-red in Android?

How do I know if device has Infra-red hardware in android pragmatically?

I want to have some things to be done based on this. I tried using something like below, but no luck.

this.getPackageManager().hasSystemFeature( .. various constants ..) 

Upvotes: 2

Views: 1835

Answers (2)

Yaqoob Bhatti
Yaqoob Bhatti

Reputation: 1575

Try Following Code

Kotlin:

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");
        }

Upvotes: 1

Related Questions