2 sinat 31167633 sinat_31167633 于 2016.03.09 10:34 提问

广播接收,判断屏幕状态 10C
 public class MyReciver1 extends BroadcastReceiver{
        public void onReceive(Context arg0, Intent arg1) {
            if(arg1.getAction().equals("com.android.lenovo.smartswitch.changemode")){
                mc++;
                msg = arg1.getStringExtra("smartswitchmode");
                sb.append("\n");
                sb.append("time :" + ConverToString(new java.util.Date()));
            }
            if(arg1.getAction().equals("android.hardware.smartpad.action.SMARTPAD_STATE")){
                 msg1 = arg1.getIntExtra("smartpad_mode", 9999);
                 msg2 = arg1.getIntExtra("ctp_mode", 9999);
                 msg3 = arg1.getIntExtra("emr_mode", 9999);
            }
            tvmode.setText(msg);
            tvchange.setText(mc+"");

            devices(msg,msg1,msg2,msg3);
            countfail();
            tv1.setText(sb);
            }
        }
        private void devices(String msg,int msg1,int msg2,int msg3) {
        if(i==1){
            if(msg.equals("laptop")){
                tv1.setText("");
                if(msg1==0&&msg2==0&&msg3==2){
                    sb.append("SMARTPAD_MODE : " + msg1 + "\t");
                    sb.append("CTP_MODE : " + msg2 + "\t");
                    sb.append("EMR_MODE : " + msg3 + "\t");
                    sb.append("\t" + "TRUE" + "\t");
                }else {
                    sb.append("\t" + "FALSE " + "\t");
                }
            }
            if(msg.equals("tent")){
                tv1.setText("");
                if(msg1==4&&msg2==2&&msg3==2){
                    sb.append("SMARTPAD_MODE : " + msg1 + "\t");
                    sb.append("CTP_MODE : " + msg2 + "\t");
                    sb.append("EMR_MODE : " + msg3 + "\t");
                    sb.append("\t" + "TRUE" + "\t");
                }else{
                    sb.append("\t" + "FALSE " + "\t");
                }
            }

            if(msg.equals("tablet")){
                tv1.setText("");

                    sb.append("SMARTPAD_MODE : " + msg1 + "\t");
                    sb.append("CTP_MODE : " + msg2 + "\t");
                    sb.append("EMR_MODE : " + msg3 + "\t");
                    sb.append("\t" + "TRUE" + "\t");



        }
            i = 0;
        }else{
            i =1 ;
        }
    }

1个回答

hnxcjsbzzysljf
hnxcjsbzzysljf   2016.10.08 01:30

sb.append("time :" + ConverToString(new java.util.Date()));
}
if(arg1.getAction().equals("android.hardware.smartpad.action.SMARTPAD_STATE")){
msg1 = arg1.getIntExtra("smartpad_mode", 9999);
msg2 = arg1.getIntExtra("ctp_mode", 9999);
msg3 = arg1.getIntExtra("emr_mode", 9999);
}
tvmode.setText(msg);
tvchange.setText(mc+"");

        devices(msg,msg1,msg2,msg3);
        countfail();
        tv1.setText(sb);
        }
    }
    private void devices(String msg,int msg1,int msg2,int msg3) {
    if(i==1){
        if(msg.equals("laptop")){
            tv1.setText("");
            if(msg1==0&&msg2==0&&msg3==2){
                sb.append("SMARTPAD_MODE 
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!