根据官方的api: dispatchMessage(Message msg) Handle system messages here. 是处理的系统Message你试试这个方法:sendMessage (Message msg) Pushes a message onto the end of the message queue after all pending messages before the current time. It will be received in handleMessage(Message), in the thread attached to this handler. 这个返回的是boolean型,是看看是否发送成功,你可以不用接收返回值。把log给粘一下,大家帮你看看。
dispatchMessage(Message msg) Handle system messages here. 是处理的系统Message你试试这个方法:sendMessage (Message msg) Pushes a message onto the end of the message queue after all pending messages before the current time. It will be received in handleMessage(Message), in the thread attached to this handler.
这个返回的是boolean型,是看看是否发送成功,你可以不用接收返回值。把log给粘一下,大家帮你看看。
我猜测你
private Handler handler = new Handler() {
//这里面的有问题,应该是某个对象未初始化
}
public void handleMessage(Message msg){
if (msg.what == 0) {
//CFlag=true;
//Toast.makeText(aa.this,"get0", Toast.LENGTH_LONG).show();
//btnChange.setBackgroundDrawable(getResources().getDrawable(R.drawable.btnoff));
}
else if(msg.what==1){
//CFlag=false;
//Toast.makeText(aa.this,"get1", Toast.LENGTH_LONG).show();
//btnChange.setBackgroundDrawable(getResources().getDrawable(R.drawable.btnon));
} super.handleMessage(msg);
}
};