我在某个时候建立了一个Android应用程序以控制我的空调,它曾经在Android 4.1中工作正常(我使用的是HTC M8手机),现在升级到5.0棒棒糖后它停止工作我附加了一个样本片段
没有调试错误,表示IR已传输。
- 空调品牌三星(包括开关的红外代码)
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);
}
});
这是一个接近但无法提供帮助的链接。 Stack Overflow reference
有人可以帮我把东西放在一起,或者我错过了什么吗?
答案 0 :(得分:1)
在Android 4.4.3之前,模式的每个元素都是开/关脉冲的周期数。
对于Android 4.4.3及以上版本的每个元素,如果开/关脉冲的微秒数。
答案 1 :(得分:0)
好的,所以最初API支持脉冲,我建立它现在它们支持持续时间,以微秒为单位,因为我的原始数据是比特我没有触及那个,而是在我的getter中我确实选择修改和传输
因此公式代表duration = (1000000 / frequency) * pulse
并传输持续时间不是脉冲的数组。
//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应该工作HTC在IR API上有一个顶峰。望着