AsyncTaskを使用できます。
AsyncTask では、 で行うことができますdoInBackground。publishProgressタスク中に、メソッドによってキャッチされるメソッドを呼び出して進行状況を投稿できますonProgressUpdate。また、タスクが終了すると、onPostExecuteメソッドが呼び出されます。それがあなたが望むものです。
だから、あなたがこれをそのようなことをするために必要なのは
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
protected Long doInBackground(URL... urls) {
// Do your task and during the task calculate the progress and call publishProgress to publish the progress
return totalSize;
}
protected void onProgressUpdate(Integer... progress) {
progress received
}
protected void onPostExecute(Long result) {
task finihshed
}
}