<pre>I want to display name of file in progress bar in while copy all files my code is.. public CopyTask() { dialog = new ProgressDialog(MainActivity.this); dialog.setTitle("Copying " + getName() ); dialog.setMessage("Copying a file to the internal storage, this can take some time!" + getName() ); dialog.setIndeterminate(false); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setCancelable(true); dialog.setButton(ProgressDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialog.cancel(); CopyTask.this.cancel(true); } }); }
getName()
CopyTask()
class CopyTask extends AsyncTask<Void, String, Void> { ProgressDialog dialog = null; protected void onPreExecute() { dialog = new ProgressDialog(MainActivity.this); dialog.setTitle("Copying file..."); dialog.setIndeterminate(true); dialog.setCancelable(false); dialog.show(); } protected Void doInBackground() { for (int x = 0; x < num_files_to_copy; x++) { String name_of_file_to_copy = array_of_files[x]; publishProgress(name_of_file_to_copy); copyFile(...); } } protected void onProgressUpdate(String... values) { dialog.setMessage(values[0]); } protected void onPostExecute() { dialog.dismiss(); } }
checkSelfPermission()
shouldShowRequestPermissionRationale()
requestPermissions()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)