标签:
public class GetData extends AsyncTask<String, Void, String>
{
DataDownloadListener dataDownloadListener;
public GetData()
{
}
public void setDataDownloadListener(DataDownloadListener dataDownloadListener) {
this.dataDownloadListener = dataDownloadListener;
}
@Override
protected Object doInBackground(Object... param)
{
return null;
}
@Override
protected void onPostExecute(Object results)
{
if(results != null)
{
dataDownloadListener.dataDownloadedSuccessfully(results);
}
else
dataDownloadListener.dataDownloadFailed();
}
public static interface DataDownloadListener {
void dataDownloadedSuccessfully(Object data);
void dataDownloadFailed();
}
}
在Activity中使用:
GetData getdata = new GetData(); getdata.setDataDownloadListener(new DataDownloadListener() { @SuppressWarnings("unchecked") @Override public void dataDownloadedSuccessfully(Object data) { } @Override public void dataDownloadFailed() { } }); getdata.execute("");
标签:
原文地址:http://www.cnblogs.com/manmanlu/p/4704314.html