In my android application in activity I am checking the if file exists or not. If not I want to download as well as display progress dialog. Once download completed dismiss the progress dialog and continue the activity.
Asked
Active
Viewed 301 times
-7
-
1You can use the first option in [this](http://stackoverflow.com/a/3028660/2652124) To start an activity, you can start it after `progressDialog.dismiss()` in `onPostExecute` method. – Renan Bandeira Aug 08 '13 at 11:05
-
Check if exists - if not, then start an `AsyncTask`. There in the `doInBackground` method download it and in the `onProgressUpdate` method set up your progress bar. – g00dy Aug 08 '13 at 11:08
-
What's your real need? 1.file existence checking, 2. download with progress, 3. start new activity. Which one? – Nizam Aug 08 '13 at 11:35
2 Answers
1
How to start a Activity after downloading the file?
Probably i assume that you are using AsyncTask
for your task.
Then this can be simply done with onPostExecute() method that is invoked when your task is done (doInBackround() method finished). Method is synchronized with Main (UI) Thread and allows operations with UI.
So in this method you can put something like this:
Intent i = new Intent(<context>, TargetActivity.class);
//i.putExtra("key",<data>) // if you want wrap some additional data
<context>.startActivity(i);

Simon Dorociak
- 33,374
- 10
- 68
- 106
0
Intent mIntent=new Intent(Context.ActivityName,Target.class);// Eg: new Intent(ThisClass.this,TargetClass.class);
mContext.startActivity(mIntent);
use like this

Nizam
- 5,698
- 9
- 45
- 57

FarhaSameer786
- 370
- 1
- 4
- 12