0
我收到以下錯誤:
09-13 06:27:02.268: E/AndroidRuntime(476): at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1961)
09-13 06:27:02.268: E/AndroidRuntime(476): at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:794)
09-13 06:27:02.268: E/AndroidRuntime(476): at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1315)
09-13 06:27:02.268: E/AndroidRuntime(476): at android.os.AsyncTask.execute(AsyncTask.java:394)
而下面是我的代碼:
private class DownloadVerses extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
String resultString = "";
try {
boolean resultBoolean = Utils.downloadTurboVerseFile(params[0]);
if(resultBoolean){
int progressPercentage = Integer.parseInt(params[2].substring(0,params[2].indexOf(".")));
resultString = "Downloading: "+params[1];
}
else{
resultString = "ERROR Downloading: "+params[1];
this.doInBackground(params);
}
} catch (Exception e) {
Thread.interrupted();
String exceptionString = e.toString();
}
return resultString;
}
@Override
protected void onPostExecute(String result) {
if(result.contains("ERROR")){
downloading.setTextColor(Color.parseColor("#f05036"));
}
else{
downloading.setTextColor(Color.parseColor("#79a1ad"));
}
downloading.setText(result);
if(checkIfVersesDownloaded()){
downloadProgressBar.setVisibility(View.INVISIBLE);
downloading.setText("Verses Have Been Downloaded.");
homeButton.setEnabled(true);
homeButton.setVisibility(View.VISIBLE);
}
}
@Override
protected void onPreExecute() {}
@Override
protected void onProgressUpdate(Void... values) {}
}
我執行這樣的代碼:
while(i < verseTitles.size()){
new DownloadVerses().execute(verseMp3s.get(i), verseTitles.get(i),progressString);
i++;
}
我在想這可能是一個簡單的解決方案,需要向我的DownloadVerses私人課程添加一些代碼?
'verseTitles.size()'有多大? – CommonsWare 2014-09-13 12:49:45
verseTitles是139,但它可能高達250.但我們只是說139。 – james0200101 2014-09-13 13:52:54