Search code examples
androidinfrared

Get null when calling getSystemService("CONSUMER_IR_SERVICE")


I'm trying to build a very simple Remote App for my TV. After some research I found the ConsumerIrManagerClass, but when I call this.getSystemService("CONSUMER_IR_SERVICE"); I get null...

The mobile is a Samsung Galaxy S4 so it has an IR Sensor...

Here's the code of my method:

public void btnOnOff_Click(View view) {
    String command = "0000 0073 0000 000c 0020 0020 0020 0020 0040 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0040 0020 0020 0040 0020 0020 0cbf";
    irManager = (ConsumerIrManager) this.getSystemService("CONSUMER_IR_SERVICE");
    irManager.transmit(36000, hexToDec(command));
}

Does anyone know how to solve this?


Solution

  • You should use the Context.CONSUMER_IR_SERVICE constant as parameter.

    It's value is "consumer_ir", not "CONSUMER_IR_SERVICE".