I want to select and upload images from my sdcard of device using my application while it is selecting and uploading the image i wanted to show progress dialog and once uploading is complete dismiss the progress dialog but it should show the dialog until unless file is uploaded completely no matter what is the size of image.
Asked
Active
Viewed 46 times
3 Answers
1
Try using AsyncTask.
Show Progress dialog in onPreExecute()
Upload your image in doInBackground()
dismiss the progress dialog in onPostExecute()
The flow will be, first of all onPreExecute()
will be called then doInBackground()
will be called and when whatever task being done in doInBackground()
will finish, onPostExecute()
will be called. You can use this to achieve what you want.

gprathour
- 14,813
- 5
- 66
- 90
-
I doing parsing and UI creation inside one method that whoole task i wanted to do in background and after completion of whole task want to return success or failure result, during this process i am not sure how much time it will take beacause the size of image can be anything , but i need to show progress dilog during whole process. – maanbhati Jan 15 '15 at 10:31
-
@user1049718 It can be achieved by AsyncTask. Just move your method's code to `doInBackground()` of AsyncTask. For more info, read about it. – gprathour Jan 15 '15 at 10:42
-
No I am having some UI operation inside my method and UI related task can not be done inside doInBackgroud method. – maanbhati Jan 15 '15 at 11:35
-
@user1049718 You can do it by `runOnUiThread`. [check out this](http://developer.android.com/reference/android/app/Activity.html#runOnUiThread%28java.lang.Runnable%29) and [this](http://stackoverflow.com/questions/11140285/how-to-use-runonuithread) – gprathour Jan 15 '15 at 12:49
0
We can use AsynckTask, Services, Intent Service etc for performing long running operation.

maanbhati
- 103
- 1
- 4
- 11