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?
-
Use Context.CONSUMER_IR_SERVICE instead of a hard coded string. You may be using the wrong one.Gabe Sechan– Gabe Sechan2014年05月24日 21:40:00 +00:00Commented May 24, 2014 at 21:40
2 Answers 2
You should use the Context.CONSUMER_IR_SERVICE constant as parameter.
It's value is "consumer_ir", not "CONSUMER_IR_SERVICE".
Comments
Also to be clear: it is an IR emitter, not a sensor. The sensor is on the equipment you are controlling.
Chances are if you are doing: Context.CONSUMER_IR_SERVICE and you get NULL your phone does not support this feature. Try a free IR app in the Play store first to see if that works.