Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9069965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:33:53+00:00 2026-06-16T17:33:53+00:00

Hi iam trying to retrieve the contact images from the phone into my arrayadapter

  • 0

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) {

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:33:54+00:00Added an answer on June 16, 2026 at 5:33 pm

    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

    imageLoader.displayImage(contactFilePath, holder.image, displayImageOptions);
    

    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);

            listView = (ListView) findViewById(android.R.id.list);
    
            new asynGetContacts().execute();
    
        }
    
        protected class asynGetContacts extends AsyncTask<String, Void, Integer> {      
            protected Integer doInBackground(String... params) {
                try {
                    ImageListActivity.this.runOnUiThread(new Runnable() {
                        public void run() {
                            dialog = ProgressDialog.show(ImageListActivity.this, "","Lütfen bekleyin...", true);
                            dialog.show();
                        }
                    });
                    Uri uri = ContactsContract.Contacts.CONTENT_URI;
                    ContentResolver cr = getContentResolver();
                    String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
                            + " COLLATE LOCALIZED ASC";
                    Cursor cur = cr.query(uri, null, null, null, sortOrder);
                    if (cur.getCount() > 0) {
                        String id;
                        String name;
                        while (cur.moveToNext()) {
                            Contact c = new Contact();
                            id = cur.getString(cur
                                    .getColumnIndex(ContactsContract.Contacts._ID));
                            name = cur
                                    .getString(cur
                                            .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                            Uri my_contact_Uri = Uri.withAppendedPath(
                                    ContactsContract.Contacts.CONTENT_URI,
                                    String.valueOf(id));
    
                            InputStream inputStream = ContactsContract.Contacts
                                    .openContactPhotoInputStream(getContentResolver(),
                                            my_contact_Uri);
                            BufferedInputStream buf = new BufferedInputStream(inputStream);
                            Bitmap my_btmp = BitmapFactory.decodeStream(buf);
    
                            if (my_btmp != null) {
                                c.photo = my_btmp;
                                c.id = id;
                                c.name = name;
                                c.photoURL = saveToSD(my_btmp, id);
                                contactList.add(c);
                            }
                        }
                    }
                    cur.close();
    
    
    
                } catch (Exception e) {
                    Log.v("hata", e.toString());
                    return 0;
                }
    
                return 1;
            }
    
            protected void onPostExecute(Integer result) {
                try {
                    dialog.dismiss();
                    adapterContact = new AdapterContact(ImageListActivity.this, 0,
                            contactList);
                    listView.setAdapter(adapterContact);
                    listView.setOnScrollListener(new PauseOnScrollListener(false, true));
                } catch (Exception e) {
                    Log.v("hata", e.toString());
                }
    
                super.onPostExecute(result);
            }
        }
    
        public String saveToSD(Bitmap bmp, String id) { 
            String file_path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/ContactImage/";
    
            try {
                File dir = new File(file_path);
    
                if (!dir.exists())
                    dir.mkdirs();
    
                File f = getFileStreamPath(file_path);
    
                if (!f.exists()) {
                    File file = new File(dir, "contact_" + id + ".png");
                    FileOutputStream fOut = new FileOutputStream(file);
                    bmp.compress(Bitmap.CompressFormat.PNG, 85, fOut);
                    fOut.flush();
                    fOut.close();
                }
    
    
            } catch (Exception e) {
                Log.v("Hata", e.toString());
            }
    
            return "file://"+file_path+"contact_" + id + ".png";
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I am trying to retrieve data into an xml tag from the database using
I am trying to retrieve records from db and put them into a table.
I am trying to retrieve contact names given the contact phone number. I made
I am trying retrieve user name from the code through graph api, the below
I am trying to retrieve a column from another related table, and display that
I am trying to retrieve CLOB data from our Oracle database. the code is
I am trying to retrieve each photo album from facebook by using php. I
I am trying to retrieve files (.csv) from an ftp site and save them
I am new to Android and now trying to retrieve contact photo (thumb nail)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.