Android 4.4 后 IR 传输 ConsumerIrManager class 不工作
IR transmit ConsumerIrManager class after Android 4.4 not working
我曾经构建了一个 Android 应用程序来控制我的空调,它曾经在 Android 4.1 中运行良好(我使用的是 HTC M8 phone),现在之后升级到 5.0 Lollipop 它停止工作我附上了一个示例片段。
没有调试错误,它说 IR 已传输。
--空调品牌Samsung(含开关机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);
}
});
这里有一个 link 就在附近但帮不上忙。
Stack Overflow reference
谁能帮我把东西放在一起,或者如果我遗漏了什么??
之前Android 4.4.3模式的每个元素是on/off脉冲的周期数。
对于Android 4.4.3及以上模式的每个元素如果微秒数为on/off脉冲。
好的,所以最初 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 的三星 phone。也没有检查 LG phone。但根据我的研究,三星和 LG 应该可以工作 HTC 在 IR 上有一个顶级 API。眺望
我曾经构建了一个 Android 应用程序来控制我的空调,它曾经在 Android 4.1 中运行良好(我使用的是 HTC M8 phone),现在之后升级到 5.0 Lollipop 它停止工作我附上了一个示例片段。
没有调试错误,它说 IR 已传输。
--空调品牌Samsung(含开关机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);
}
});
这里有一个 link 就在附近但帮不上忙。 Stack Overflow reference
谁能帮我把东西放在一起,或者如果我遗漏了什么??
之前Android 4.4.3模式的每个元素是on/off脉冲的周期数。
对于Android 4.4.3及以上模式的每个元素如果微秒数为on/off脉冲。
好的,所以最初 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 的三星 phone。也没有检查 LG phone。但根据我的研究,三星和 LG 应该可以工作 HTC 在 IR 上有一个顶级 API。眺望