gpt4 book ai didi

android - AsyncHttpClient OnSuccess 未执行

转载 作者:行者123 更新时间:2023-11-30 02:06:22 25 4
gpt4 key购买 nike

这是我在控制台中得到的:

onSuccess(int, Header[], JSONObject) was not overriden, but callback was received

我已验证,文件已上传到服务器。

这是我的代码,应用程序没有提示:

public void uploadImage() {
//Create a new RequestParams that will send paremeters with our AsyncHttpClient request.
RequestParams data = new RequestParams();

//Adding our image to the parameters.
File image = new File(imgPath);
try {
data.put("image", image);
} catch(FileNotFoundException e) {}
//Create a new AsyncHttpClient request.
//here we're sending a POST request, the first parameter is the request URL
// then our RequestParams, in our case data and then a Json response handler.
AsyncHttpClient client = new AsyncHttpClient();
client.post(FILE_UPLOAD_URL, data, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header headers[], JSONArray success) {
try {
JSONObject data = success.getJSONObject(0);
String m = data.getString("message");
Toast.makeText(UploadPhotoTest.this, m, Toast.LENGTH_LONG).show();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}

如果相关,这就是我要导入的内容:

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

我的问题是 OnSuccess 中的任何内容都不会被执行。我在 OnSuccess try and catch 中放置了一个日志,但没有打印任何内容。我该如何解决这个问题?

最佳答案

public void onSuccess(int statusCode, Header[] headers, JSONObject response) {

这对我有用。

关于android - AsyncHttpClient OnSuccess 未执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30616354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com