0

In my app i'm displaying a list with a checkbox for each item. when user clicks on a button my app should import each checked item(Contact) to contacts app. i am trying to show the user the progress(ItemIndex/TotalItems) + text of the current item (by using progress dialog). Meanwhile my app is checking for each item (contact) it is already exist in the contacts app, and if so, a dialog will be displayed (this dialog is an activity - dialog themed) by using stratActivityForResult. I've tried to use asynctask and all it does is to show a progress dialog with the first item and nothing more. I also tried to use handler and it does the same thing.

can anyone help me?

EDIT:

int filesIndex=0;
ArrayList selectedFiles<String>;
startImport();

private void StartImport(final ArrayList<String> Files) 
{
  //checks if there's allready an existing item and if there is, call  displayConflict();

}




private void displayConflict(String file1, String file2) 
{
  startActivityForResult....//call an activity that looks like a dialog....

}



 public void onActivityResult(int requestCode, int resultCode, Intent data) 
{
  //use data....
  operate();//addnew / update / skip
  MoveNext();
}



protected void Movenext()
{
  filesIndex++; //------------> this is the step where I want to update ui with progressDialog....
  StartImport();
}
  • AsyncTask should be OK. Update the `ProgressDialog` at `onProgressUpdate` and call `publishProgress` as needed from `doInBackground`. – m0skit0 Nov 17 '13 at 14:18

1 Answers1

-1

In case, you are using AsyncTask the job is pretty simple. As you have to get the value in percent of your running job and pass it as an int using publishProgress(progress) where progress is the calculated value (status) of the ongoing task.

Then, override onProgressUpdate of AsyncTask which will take the value you passed using publishProgress(progress) and update your progressBar in this method.

You can refer the links below for more help :

https://stackoverflow.com/a/7592623/1235555

Example

Community
  • 1
  • 1
user1235555
  • 335
  • 4
  • 19
  • well, that's the problem ...the heavy work is not inside the task it's in the activity and that's the way it has to be because I need to interact with the user . Do you have any other solution? – user2678140 Nov 18 '13 at 08:18