我收到附加代码的以下错误。这里的问题是即使在退出“for”循环之后线程仍在运行。我所做的只是单击一个按钮,我将一堆文件上传到云端。ListofDocs[]
是我存储要上传的文件列表的位置。任何帮助表示赞赏。TIA。
11-03 21:23:27.793: E/AndroidRuntime(24480): FATAL EXCEPTION: Thread-11897
11-03 21:23:27.793: E/AndroidRuntime(24480): java.lang.ArrayIndexOutOfBoundsException: length=12; index=12
11-03 21:23:27.793: E/AndroidRuntime(24480): at com.projects.scloud.PicsList$1$1.run(PicsList.java:99)
11-03 21:23:27.793: E/AndroidRuntime(24480): at java.lang.Thread.run(Thread.java:856)
for(i=0; i < ListofDocs.length; i++) {
Log.i("Value of i: ", String.valueOf(i));
MessageText.setText("Upload Documents");
/************* Php script path ****************/
upLoadServerUri = "http://www.androidexample.com/media/UploadToServer.php";
Backup.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog = ProgressDialog.show(DocsList.this, "", "Uploading file...", true);
new Thread(new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
MessageText.setText("uploading started.....");
}
});
uploadFile(ListofDocs[i]);
}
}).start();
}
});
}