我的主程序主要是实现从服务器上下载4个int型数据,然后传给主线程,但是怎么也传不出来,求大神帮助。
代码一:连接服务器线程中的代码
Message msg = mHandler.obtainMessage();
Bundle bundle=new Bundle();
bundle.putInt("X", 10);
bundle.putInt("Y", y);
bundle.putInt("WIDTH", width);
bundle.putInt("HEIGTH", height);
msg.setData(bundle);
msg.sendToTarget();
代码二:主线程中的代码
mHandler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
Bundle bundle=msg.getData();
L_x=bundle.getInt("X");
L_y=bundle.getInt("Y");
L_width=bundle.getInt("WIDTH");
L_height=bundle.getInt("HEIGTH");
}
};
代码一:连接服务器线程中的代码
Message msg = mHandler.obtainMessage();
Bundle bundle=new Bundle();
bundle.putInt("X", 10);
bundle.putInt("Y", y);
bundle.putInt("WIDTH", width);
bundle.putInt("HEIGTH", height);
msg.setData(bundle);
msg.sendToTarget();
代码二:主线程中的代码
mHandler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
Bundle bundle=msg.getData();
L_x=bundle.getInt("X");
L_y=bundle.getInt("Y");
L_width=bundle.getInt("WIDTH");
L_height=bundle.getInt("HEIGTH");
}
};
Bundle bundle=new Bundle();
bundle.putInt("X", 10);
bundle.putInt("Y", y);
bundle.putInt("WIDTH", width);
bundle.putInt("HEIGTH", height);
msg.setData(bundle);
msg.sendMessage(msg);