源:http://www.cnblogs.com/xiaochao1234/p/3615467.html
经过连续几天的编制,安卓手机代码终于完成了,目前已经将我宿舍,家里,集控室的红外遥控电气设备完好的遥控了,另外还遥控了我的D7000相机,不错终于完工了。 代码分为二类: 各种电视、相机、等等遥控编码最简单,只要将按键的编码复制下来,直接变成手机发射码就可以了。(这种编码单个按键只发射单个信息) 最难的是空调编码,由于空调编码是将单个按键要发射所有控制信息,如增加一度温度,同时要将控制模式、温度、风量等等所有信息一同发射出去,还有检验码,通过长时间实验,如果像一般模仿遥控器的设备(例如万能遥控器)编码是将各种组合分别保存起来,这要就很长,也很麻烦,但用第一种方法实现起来就很容易。第二种方法主要是找规律比较麻烦,而且要再程序中变成组合再变成安卓发射码,比较麻烦。 经过摸索 格力遥控器编码规则如下(前面的资料是网上搜集来的,这里是自己总结的):
**文件格式:开关名称 / 按键位置 / 图标名称 / 命令代码
**空调格式:格力空调YB0FB
** 0 1 2 3方式 4开5风6睡 7温度 8 10强照 干
++++/24,65,22/38000,358,179/ 100/ 0 /00/00 /0101 /0000 /0000/ 0/0/0/0 /0000 /1010 /010/ ,24,795 /0000 /0000 /1000 /0100 /0000 /0000 /0000 /++
**名称/位置/图标/位置/初始值/变化
++/空调开关/20/power/4/2
++/模式/21/mode/3/5/p1/auto/coldm/dryingm/windm/warmm
++/风量/22/velocity/5/4/t2/wind0/wind1/wind2/wind3
++/温度+/23/up/7/14/t1/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30
++/温度-/28/down/7/14/t1/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30
++/灯光/25/light/11/2/p3/nu/lightm
++/睡眠/26/sleep/6/2/p4/nu/sleepm
这上面是格力空调编码方案
下面是直接编码:
电视开关/0/power/38000,358,179,21,21,22,21,23,20,21,21,22,21,23,20,21,67,23,20,21,21,22,21,23,20,21,21,22,21,23,20,21,67,23,20,21,21,22,67,21,21,22,67,21,21,22,21,23,20,21,21,22,67,21,21,22,67,21,21,22,67,21,67,23,64,22,67,21,1310,358,89,22
静音/6/mute/38000,361,176,22,21,21,21,22,21,21,22,21,21,22,21,21,67,22,21,21,22,21,21,22,21,21,22,22,20,23,20,21,67,23,20,21,67,23,65,22,65,21,67,23,20,21,22,23,19,24,19,21,22,23,19,24,19,21,22,23,64,21,67,24,64,23,64,21,1310,359,88,21
显示模式/5/screen/38000,359,178,22,21,25,18,21,21,22,21,25,18,21,21,22,67,21,21,22,21,25,18,21,21,22,21,25,18,21,21,22,67,21,21,22,67,21,21,22,21,25,63,22,67,21,21,22,21,25,18,21,21,22,67,21,67,25,18,21,21,22,67,21,67,25,63,22,1309,359,89,25
信号源/1/tvav/38000,362,175,24,20,21,21,22,21,24,20,21,21,22,21,24,64,22,21,24,20,21,21,22,21,24,20,21,21,22,21,24,64,22,21,24,64,22,21,24,20,21,21,22,21,24,20,21,67,24,20,21,21,22,67,21,67,24,64,22,67,21,67,24,20,21,67,24,1307,362,86,21
下面是安卓语言源代码:不喜好编程的人就不用看了:(感兴趣的朋友可以联系我,图片上有QQ号)
package com.example.sumxingir;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.util.EncodingUtils;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class room extends Activity {
String Temp;
String[] STR=new String[2];
String[] rv=new String[2];
private MyAdapter adapter = null;
private ArrayList