switch (view.getId()) {
case R.id.trimmBttn:
final Integer stime[] = { 2, 4, 7, 9, 12, 18 };
final Integer endTime[] = { 4, 6, 9, 11, 15, 20 };
Thread thread = new Thread(new Runnable() {
@Override public void run() {
for (int i = 0; i < stime.length; i++) {
trimmVideo = new TrimmVideo(getExternalFilesDir(null) + "/12.mp4", stime[i],
endTime[i]).execute();
}
}
});
thread.start();
try {
thread.join();
} catch (InterruptedException e) {
}
break;
}
private class TrimmVideo extends AsyncTask<Void, Void, Void> {
private String mediaPath;
private double startTime;
private double endTime;
private int length;
private ProgressDialog progressDialog;
private TrimmVideo(String mediaPath, int startTime, int length) {
this.mediaPath = mediaPath;
this.startTime = startTime;
this.length = length;
this.endTime = this.startTime + this.length;
}
@Override protected void onPreExecute() {
progressDialog = ProgressDialog.show(context, "Trimming videos", "Please wait...", true);
super.onPreExecute();
}
@Override protected Void doInBackground(Void... params) {
trimVideo();
return null;
}
@Override protected void onPostExecute(Void result) {
progressDialog.dismiss();
super.onPostExecute(result);
}
This is my code i want to execute Asyck task synchronously inside for loop i.e when loop start from 0 then for 0 value its completed task then it should start for value next asynk task execution if 1 is complted then for 2 and so on ... please suggest me i am trying to using thread with join but still not working .