InvoiceTemplateGet 类型未定义方法 execute()
The method execute() is undefined for the type InvoiceTemplateGet
我使用 AsyncTask 从 API 获取结果。我有几个 classes 可以正常工作。我创建了另一个 AsyncTask class,但出现此错误:
The method execute() is undefined for the type InvoiceTemplateGet
这一行:
InvoiceTemplateGet template = new InvoiceTemplateGet(PaymentMethodActivity.this, invoiceNumber);
template.execute();
有 class InvoiceTemplateGet:
public class InvoiceTemplateGet {
public InvoiceTemplateGet(Context context, String invoiceNumber){
mContext = context;
this.invoiceNumber = invoiceNumber;
load_default_settings();
}
protected CustomAsyncTaskResult<String> doInBackground(String... arg0) {
try{
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = httpclient.execute(httpget,responseHandler);
return new CustomAsyncTaskResult<String>(response);
}catch (HttpResponseException e){
return new CustomAsyncTaskResult<String>(new ApiException("Invoice", "Invoice was not found."));
}catch (Exception e){
Log.e("Invoice Error", "Error:", e);
return new CustomAsyncTaskResult<String>(new ApiException("Invoice", e.getMessage()));
}
}
protected void onPostExecute(CustomAsyncTaskResult<String> result) {
((PaymentMethodActivity)mContext).getResultFromTemplate(result);
progressDialog.dismiss();
}
}
我还有一个class,和这个一样,只是url不一样。它像这个一样在同一页面上执行,在代码的同一部分。它有效,为什么我仍然收到此错误?
I have another class which is the same like this one, just url is
different. It's executed on the same page like this one, on the same
part of code. And it works, so why I'm still getting this error?
您的 InvoiceTemplateGet
没有名为 execute()
的方法。查看您的代码,在我看来您忘记了 extend AsyncTask
。您还可以创建实例化内部 AsyncTask
并调用 instance.execute()
的 execute() 方法
我使用 AsyncTask 从 API 获取结果。我有几个 classes 可以正常工作。我创建了另一个 AsyncTask class,但出现此错误:
The method execute() is undefined for the type InvoiceTemplateGet
这一行:
InvoiceTemplateGet template = new InvoiceTemplateGet(PaymentMethodActivity.this, invoiceNumber);
template.execute();
有 class InvoiceTemplateGet:
public class InvoiceTemplateGet {
public InvoiceTemplateGet(Context context, String invoiceNumber){
mContext = context;
this.invoiceNumber = invoiceNumber;
load_default_settings();
}
protected CustomAsyncTaskResult<String> doInBackground(String... arg0) {
try{
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = httpclient.execute(httpget,responseHandler);
return new CustomAsyncTaskResult<String>(response);
}catch (HttpResponseException e){
return new CustomAsyncTaskResult<String>(new ApiException("Invoice", "Invoice was not found."));
}catch (Exception e){
Log.e("Invoice Error", "Error:", e);
return new CustomAsyncTaskResult<String>(new ApiException("Invoice", e.getMessage()));
}
}
protected void onPostExecute(CustomAsyncTaskResult<String> result) {
((PaymentMethodActivity)mContext).getResultFromTemplate(result);
progressDialog.dismiss();
}
}
我还有一个class,和这个一样,只是url不一样。它像这个一样在同一页面上执行,在代码的同一部分。它有效,为什么我仍然收到此错误?
I have another class which is the same like this one, just url is different. It's executed on the same page like this one, on the same part of code. And it works, so why I'm still getting this error?
您的 InvoiceTemplateGet
没有名为 execute()
的方法。查看您的代码,在我看来您忘记了 extend AsyncTask
。您还可以创建实例化内部 AsyncTask
并调用 instance.execute()