android中while循环中的sendMessage方法

</pre><p></p><p><pre name="code" class="java">while ((length = is.read(bt, 0, bt.length)) > 0) {
			            	sumL += length;
			            	Message msg = new Message();
			            	msg.what = 22;
			            	msgb.putDouble("kb", sumL/l);
			            	msg.setData(msgb);
			            	handler.sendMessage(msg);
			                fos.write(bt, 0, length);  
			                fos.flush();      
			            }  


必须将msg初始化放到循环内,相当于重新建立Message对象,才能发送消息

你可能感兴趣的:(android中while循环中的sendMessage方法)