I have an app in android which retrieve a picture from http page.I’m asking for this picture using an AsyncTask thread.
This is how I do it:
mPostButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
for(int i=0;i<friends.size();i++)
{
getUserPic(friends.get(i).getId());
}
}
});
I have an ArrayList called friends and for every item of the list I’m calling the method: getUserPic() which executes a AyncTask thread:
public void getUserPic(String userID){
final String imageURL;
Bitmap bitmap=null;
imageURL = "http://graph.facebook.com/"+userID+"/picture?type=small";
task.execute(new String[] {imageURL});
}
So everytime is called getUserPic() uses an AsyncTask thread to call for the imageURL.
The problem is that I get FC….here is how my logcat looks like:
java.lang.IllegalStateException: Cannot execute task: the task is already running.
at android.os.AsyncTask.execute(AsyncTask.java:380)
at com.facebook.android.Example.getUserPic(Example.java:129)
at com.facebook.android.Example$3.onClick(Example.java:114)
at android.view.View.performClick(View.java:2364)
at android.view.View.onTouchEvent(View.java:4179)
at android.widget.TextView.onTouchEvent(TextView.java:6540)
at android.view.View.dispatchTouchEvent(View.java:3709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
Anyone, any SOLUTION to this?Thank u!
1 Answer