Böyle bir şey yapabiliriz ..
public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
private ProgressDialog mProgressDialog;
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_DOWNLOAD_PROGRESS:
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage("waiting 5 minutes..");
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setCancelable(false);
mProgressDialog.show();
return mProgressDialog;
default:
return null;
}
}
Sonra ilerlemeyi güncellemek için bir zaman uyumsuz görev yazmayı .. Bu amaca çözmek gerekir ve alışkanlık hatta UI sırtının engellemek
private class DownloadZipFileTask extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(DIALOG_DOWNLOAD_PROGRESS);
}
@Override
protected String doInBackground(String... urls) {
//Copy you logic to calculate progress and call
publishProgress("" + progress);
}
protected void onProgressUpdate(String... progress) {
mProgressDialog.setProgress(Integer.parseInt(progress[0]));
}
@Override
protected void onPostExecute(String result) {
dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
}
}
..
İşlemi, setProgress() 'ile istediğiniz gibi ayarlayabilirsiniz. Sadece güncellemek istediğinizde arayın. – Geobits
Eğer ayarlanmış bir süre sahte bir ilerleme çubuğu yaparsa .. Belki son 5 dakikada bir gif. – NightSkyCode
AsyncTask'ın belgelerinden ... ** AsyncTask'lar kısa süreli operasyonlarda (en fazla birkaç saniye) ideal olarak kullanılmalıdır. ** - gerçekten 5 dakikalık bir AsyncTask ' – Squonk