Hi iam trying to retrieve the contact images from the phone into my arrayadapter
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) (getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE));
view = inflater.inflate(renderer, null);
}
TextView text = (TextView) view.findViewById(R.id.name);
ImageView photo = (ImageView) view.findViewById(R.id.photo);
new LoadImage(photo).execute();
i want to use asynctask to get the photos from phone, i am struck how to do that in doinbackground().. plz suggest how to get the photos from contacts , what goes under doinbackground() process
class LoadImage extends AsyncTask<Object, Void, Bitmap>{
private ImageView imv;
public LoadImage(ImageView imv) {
this.imv = imv;
}
@Override
protected Bitmap doInBackground(Object... params) {
Bitmap bitmap = null;
photo.setImageBitmap(contact.getPhoto());
}
@Override
protected void onPostExecute(Bitmap result) {
}
}
you can use universalimageloader to do this https://github.com/nostra13/Android-Universal-Image-Loader
As you see below example you can save contact photos to SD cart then put their FilePath in a list and use that path with universal imageloader,
you can take full example from https://dl.dropbox.com/u/68130108/UniversalImageLoaderExample.rar
in your adapter getView
in your Activity
public class ImageListActivity extends BaseActivity {
AdapterContact adapterContact;
DisplayImageOptions options;
String[] imageUrls;
ArrayList contactList = new ArrayList();
ListView listView;
ProgressDialog dialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_image_list);