【发布时间】:2015-09-06 21:19:22
【问题描述】:
我正在尝试制作一个应用程序来拍照,然后将照片上传到 java 中的服务器,但我无法摆脱这个错误
public void makeHTTPCall() {
prgDialog.setMessage("Invoking JSP");
AsyncHttpClient client = new AsyncHttpClient();
这是错误:
"Class '匿名类必须从asynchttpresponsehandler派生 要么被声明为抽象,要么实现抽象方法 onFailure(int, Header[], byte[], Throwable) in AsyncHttpResponseHandler"
client.post("http://192.168.2.5:9999/ImageUploadWebApp/uploadimg.jsp", params, new AsyncHttpResponseHandler() {
在下面这两个方法中,还说它们不会从超类中覆盖
@Override
public void onSuccess(String response) {
// Hide Progress Dialog
prgDialog.hide();
Toast.makeText(getApplicationContext(), response, Toast.LENGTH_LONG).show();
}
@Override
public void onFailure(int statusCode, Throwable error, String content) {
// Hide Progress Dialog
prgDialog.hide();
// When Http response code is '404'
if (statusCode == 404) {
Toast.makeText(getApplicationContext(), "Requested resource not found", Toast.LENGTH_LONG).show();
}
// When Http response code is '500'
else if (statusCode == 500) {
Toast.makeText(getApplicationContext(),
"Something went wrong at server end",
Toast.LENGTH_LONG).show();
}
// When Http response code other than 404, 500
else {
Toast.makeText(
getApplicationContext(),
"Error Occured \n Most Common Error: \n1. Device not connected to Internet\n2. Web App is not deployed in App server\n3. App server is not running\n HTTP Status code : "
+ statusCode, Toast.LENGTH_LONG)
.show();
}
}
});
}
我正在关注本教程,Tutorial
【问题讨论】: