public void run() { System.out.println(transfer.getStatus()); System.out.println(transfer.getProgress()); android.os.Message message = new android.os.Message(); // handle message.what = 3; while (!transfer.isDone()) { System.out.println(transfer.getStatus()); System.out.println(transfer.getProgress()); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (transfer.getStatus().equals(Status.error)) { msg.setReceive(MessageInfo.STATUS[2]); } else if (transfer.getStatus().equals(Status.refused)) { msg.setReceive(MessageInfo.STATUS[1]); } else { msg.setReceive(MessageInfo.STATUS[0]); // 成功 } handler.sendMessage(message); /* * System.out.println(transfer.getStatus()); * System.out.println(transfer.getProgress()); */ }
/** * 分析消息内容 * * @param body Json */ public static MessageInfo analyseMsgBody(String jsonStr) { MessageInfo msg = new MessageInfo(); // 获取用户、消息、时间、IN try { JSONObject jsonObject = new JSONObject(jsonStr); msg.setUserid(jsonObject.getString(MessageInfo.USERID)); msg.setFrom(jsonObject.getString(MessageInfo.FROM)); msg.setMsg(jsonObject.getString(MessageInfo.MSG_CONTENT)); msg.setDate(jsonObject.getString(MessageInfo.DATE)); msg.setType(jsonObject.getString(MessageInfo.MSG_TYPE)); msg.setReceive(jsonObject.getString(MessageInfo.RECEIVE_STAUTS)); msg.setTime(jsonObject.getString(MessageInfo.TIME_REDIO)); msg.setFilePath(jsonObject.getString(MessageInfo.FIL_PAHT)); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } finally { return msg; } }