解决方案 »
- 求大虾指点:Android4.0.3用HttpURLConnection的post方法连接服务器抛出IO异常 [
- 【求助】从根本上替换电源键和音量键
- 求助,想画个课程表,没思路
- 刚入门android,请问android开源到哪一个程度?
- 关于android源代码的问题
- asmack 要怎么实现文件传输??
- 百度地图SDK3.0 代码混淆后 地图功能不能正常使用 也不报错
- intent传递数据的二种方式startActivityForResult为什么不行?
- android主线程和Activity关系
- Attempt to invoke virtual method 'void com.gizwits.gizwifisdk.api.GizWifiDevice
- 获得焦点图时 弹出系统输入法怎么办?
- 如何判断手机翻转了,着急,多谢大侠!
private void submit(){
APIRequest.logStr("提交数据");
JSONObject json = new JSONObject();
try {
json.put("bill_id", id);
json.put("areas", mAreas);
json.put("brief", mStr_comment);
APIRequest.doBillCreateFromVerify(json, new Operater() {
@Override
public void OnProcessFinish(JSONObject resultJSON) {
// TODO
APIRequest.logStr(resultJSON.toString());
try {
boolean isSuccess = resultJSON.getBoolean("success");
if (isSuccess) {
Thread.sleep(700);
Intent intent = new Intent();
intent.setClass(mContext, WaitQuote.class);
intent.putExtra("data", resultJSON.getInt("data"));
startActivity(intent);
}else {
Constants.showToast(mContext, resultJSON.getString("message"));
}
}
catch (Exception e) {
// TODO
e.printStackTrace();
}
}
});
}
catch (JSONException e) {
// TODO
e.printStackTrace();
}
这是框架里的方法:
public static void doBillCreateFromVerify(JSONObject json, Operater operater) {
final Operater mCallBack = operater;
try {
json.put("user_id", getUserID());
}
catch (Exception e) {
// TODO: handle exception
}
AsyncHttpClient client = new AsyncHttpClient();
String modeString = "Trade";
String actString = "createTrade";
String dataString = json.toString();
RequestParams params = new RequestParams();
params.put("model", modeString);
params.put("action", actString);
params.put("data", dataString);
params.put("sign", md5(modeString + actString + dataString + SOME_TEXT));
client.post(APIURL, params, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers,
JSONObject response) {
super.onSuccess(statusCode, headers, response);
mCallBack.OnProcessFinish(response);
} @Override
public void onFailure(int statusCode, Header[] headers,
Throwable throwable, JSONObject errorResponse) {
super.onFailure(statusCode, headers, throwable, errorResponse);
mCallBack.OnProcessFinish(errorResponse);
}
});
}
麻烦帮看下、谢谢了