Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Progress Dialog Set Message From a Class File
    text
    copied!<p>I have the following code that downloads a video using AsyncTask.</p> <pre><code>//DOWNLOAD VIDEOS private class downloadVideosAsync extends AsyncTask &lt;String, String, String&gt;{ protected void onPreExecute(){ super.onPreExecute(); MyActivity.this.mProgressDialog.setMessage("Downloading Videos..."); } @Override protected String doInBackground(String... strings){ try{ VideosC.downloadVideos( VideosM.getVideoNames(), VideosM.getVideoUrls(), VideosM.getVideoThumbs(), VideosM.getFileModified() ); }catch (NullPointerException e){ Log.e(LOG_TAG, e.toString()); }catch(Exception e){ Log.e(LOG_TAG, e.toString()); } return null; } @Override protected void onPostExecute(String lenghtOfFile) { new downloadSlideshowsAsync().execute(); } } </code></pre> <p>As you can see I have set the message "Downloading Videos..." for my progress dialog. Now what I want to do is something like setMessage("Downloading 1 of 5"). But the problem is my downloadVideos function is in another class file VideosController.java</p> <pre><code>public void downloadVideos( ArrayList&lt;String&gt; VideoNames, ArrayList&lt;String&gt; VideoUrls, ArrayList&lt;String&gt; VideoThumbs, ArrayList&lt;String&gt; fileModified){ try{ int x; int videoNamesLenght = VideoNames.size(); File vidFile; for(x = 0; x &lt; videoNamesLenght; x++) { String[] videoName = VideoNames.get(x).split("/"); String currentFile = videoName[0] + "." + videoName[1]; String currentFileURL = VideoUrls.get(x) + VideoNames.get(x); Log.v(LOG_TAG, "currentFileURL: " + currentFileURL); vidFile = new File(Environment.getExternalStorageDirectory() + "/MyApp/Downloads/Videos/", currentFile); //I want to do maybe here something like //mProgressDialog.setMessage("Downloading x of y") downloadVideoFile(currentFile, currentFileURL, vidFile, fileModified.get(x)); } }catch(Exception e){ Log.e(LOG_TAG, e.toString()); } } </code></pre> <p>Any ideas? Thanks a lot for any help! :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload