Reputation: 17763
I have implemented a downloader, when the download is finished, I need to display upload in a list. List in separated activity I return to, when download is finished. Is there any way how to check, from where I have entered the activity? Because I need to update List and I don't know to deremine update. I have tried it in onResume, but this is invokend also after onCreate, so this doesn't solve my problem.
Thanks
Edit:
I am calling download this way:
mProgressDialog.setTitle("Downloading");
mProgressDialog.setMessage("Downloading data...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.setMax(100);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
DownloadFilesTask downloadFile = new DownloadFilesTask(DownloaderMap.this);
downloadFile.execute(myUrl);
mProgressDialog.show();
Upvotes: 0
Views: 251
Reputation: 31846
If you start your download-Activity using startActivityForResult()
, you will be returned to the onActivityResult()
method, where you will also be able to see if the download (or other action) was a success or not (use setResult()
for this).
Update:
As you are using an AsyncTask
you can just put any code you need to be run after completion in its onPostExecute()
-method. If you need to execute methods local to your Activity
, it might be easiest to just put the AsyncTask
as an internal class of the Activity
.
Upvotes: 2
Reputation: 229
If i understand your question correctly, you want to know how to tell, from a particular activity, what called it?
I'm not sure if there are other solutions to this, but the easiest one I can think of would be to put an extra on the intent when you trigger your activity, then read that out in onCreate.
e.g. when constructing your intent you'd have a line such as
newIntent.putExtra("callingActivity", this.getClass().getName());
and in the onCreate you'd read that with
this.getIntent().getStringExtra("callingActivity");
Upvotes: 0