我有一个应用程序,其中有一个名为“Images1”的单独类,它扩展了 AsyncTask,其中我通过 JSON 获取所有画廊 URL。我在另一个活动中实例化 AsyncTask 类,我需要“Images1”返回的数组列表class.However 我无法获得数组列表。请建议应该采取哪些步骤。在此先感谢
public class Images1 extends AsyncTask<Void, Void, ArrayList<String>> {
ProgressDialog mPreogressDialog;
private static String url = "http://www.tts.com/album_pro/array_to_encode";
JSONParser jParser = new JSONParser();
ArrayList<String> image_urls = new ArrayList<String>();
@Override
protected void onPreExecute() {
mPreogressDialog = ProgressDialog.show(Images1.this, "", "Uploading Document. Please wait...", true);
}
@Override
protected ArrayList<String> doInBackground(Void... params) {
// TODO Auto-generated method stub
//Do your stuff here call ur methods
imagedownload();
return image_urls;
}
protected void onPostExecute(ArrayList<String> result) {
super.onPostExecute(result);
// TODO Auto-generated method stub
if (mPreogressDialog.isShowing())
mPreogressDialog.dismiss();
}
public void imagedownload(){
JSONObject json = jParser.getJSONFromUrl(url);
try{
JSONObject seo = json.getJSONObject("SEO");
JSONArray folio = seo.getJSONArray("Folio");
JSONArray image_urls1 = new JSONArray();
String s1=seo.getString("Folio");
for(int i=0;i<folio.length();++i)
{
String m = folio.getString(i);
Log.v("M"+i,m);
image_urls.add(m+ ",");
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
在另一个活动中,我正在实例化该类并将其称为
Images1 img1;
new img1.execute();