在Android 4.4不工作后,IR传输ConsumerIrManager类

我build立了一个Android应用程序回来控制我的空调,它曾经在Android 4.1(我使用HTC M8手机)工作正常,现在升级到5.0后棒棒糖停止工作,我附上了一个示例片段。

它没有debugging错误,说红外传输。

– 空调品牌三星(包括开关的红外码)

PS:我嘲笑了所有连接的代码,

//To hold my codes for remote say on, off temp+, temp-, swing etc public class TransmissionCodes{ private int[] transmission; private int frequency; //+getters +setters +constructor } //To hold all the TransmissionCodes objects SparseArray<TransmissionCodes> sequence ; //power on sequence.put(0, new TransmissionCodes(38000, "123,339,23,54,23,14,23,16,21,14,21,16,21,14,23,16,21,16,21,14,23,53,23,15,22,16,21,54,23,14,23,16,21,16,21,54,23,54,23,53,23,54,23,14,23,54,23,14,23,54,22,54,23,16,21,16,21,14,23,14,23,16,21,16,21,54,23,54,23,15,22,15,22,14,23,14,23,14,23,14,23,53,23,54,23,14,23,14,23,16,21,54,23,14,23,16,21,14,23,16,21,14,23,16,21,14,23,53,23,53,23,54,23,54,23,2500")); //power off sequence.put(1, new TransmissionCodes(38000, "123,339,23,54,23,14,23,16,21,14,21,16,21,14,23,16,21,16,21,14,23,53,23,15,22,16,21,54,23,14,23,16,21,16,21,54,23,54,23,53,23,54,23,14,23,54,23,14,23,54,22,54,23,16,21,16,21,14,23,14,23,16,21,16,21,54,23,54,23,15,22,15,22,14,23,14,23,14,23,14,23,53,23,54,23,14,23,14,23,16,21,54,23,14,23,16,21,14,23,16,21,14,23,16,21,14,23,53,23,53,23,54,23,54,23,2500")); //IR call in main Activity findViewById(R.id.button).post(new Runnable() { public void run() { ConsumerIrManager mCIR = (ConsumerIrManager) getSystemService(android.content.Context.CONSUMER_IR_SERVICE); mCIR.transmit(sequence.getFrequency, sequence.getTransmission); } }); 

这是一个接近,但无法帮助的链接。 堆栈溢出引用

有人可以帮我把事情放在一起,或者如果我失去了什么?

Related of "在Android 4.4不工作后,IR传输ConsumerIrManager类"

在Android 4.4.3之前,模式的每个元素都是开/关脉冲的周期数。

对于Android 4.4.3及以上版本的每个元素,如果开启/closures脉冲的微秒数。

好吧,所以最初的API支持的脉冲,当我build立它现在他们支持的持续时间微秒,因为我有我的原始数据位,我没有碰到,而是在我的getter我没有select修改和传输因此,公式代表duration = (1000000 / frequency) * pulse和发射arrays的持续时间不脉冲。

 //To hold my codes for remote say on, off temp+, temp-, swing etc public class TransmissionCodes{ private int[] transmission; //will use to store and send transmssion private int frequency;//fed from my properties file private String countPattern; // Fed as string from my properties file //This modification in the getter did the trick private int[] getTransmission() { int pulses = 1000000/this.frequency; String[] countArray = this.countPattern.split(","); int[] anotherFix = new int[countArray.length]; for (int i = 0; i < countArray.length; i++) { anotherFix[i] = Integer.parseInt(countArray[i]) * pulses; } return anotherFix; } //+getters +setters +constructor } //To hold all the TransmissionCodes objects SparseArray<TransmissionCodes> sequence ; //power on sequence.put(0, new TransmissionCodes(38000, "123,339,23,54,23,14,23,16,21,14,21,16,21,14,23,16,21,16,21,14,23,53,23,15,22,16,21,54,23,14,23,16,21,16,21,54,23,54,23,53,23,54,23,14,23,54,23,14,23,54,22,54,23,16,21,16,21,14,23,14,23,16,21,16,21,54,23,54,23,15,22,15,22,14,23,14,23,14,23,14,23,53,23,54,23,14,23,14,23,16,21,54,23,14,23,16,21,14,23,16,21,14,23,16,21,14,23,53,23,53,23,54,23,54,23,2500")); //power off sequence.put(1, new TransmissionCodes(38000, "123,339,23,54,23,14,23,16,21,14,21,16,21,14,23,16,21,16,21,14,23,53,23,15,22,16,21,54,23,14,23,16,21,16,21,54,23,54,23,53,23,54,23,14,23,54,23,14,23,54,22,54,23,16,21,16,21,14,23,14,23,16,21,16,21,54,23,54,23,15,22,15,22,14,23,14,23,14,23,14,23,53,23,54,23,14,23,14,23,16,21,54,23,14,23,16,21,14,23,16,21,14,23,16,21,14,23,53,23,53,23,54,23,54,23,2500")); //IR call in main Activity findViewById(R.id.button).post(new Runnable() { public void run() { ConsumerIrManager mCIR = (ConsumerIrManager) getSystemService(android.content.Context.CONSUMER_IR_SERVICE); mCIR.transmit(sequence.getFrequency, sequence.getTransmission); } }); 

不过,我正在寻找可以应用到HTC的修复程序,因为这个修复程序只适用于具有IR的三星手机。 没有检查LG电话以及。 但基于我的研究三星和LG应该工作macros达电已在IR API的打顶。 向外看