Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

60%
+1 −0
Q&A Find image for contact list in Android Java

How to get image of contact list? I was using cursor to get contact list. Here how it looks like. ArrayList<HashMap<String, String>> contactList = new ArrayList<>(); Has...

1 answer  ·  posted 2y ago by Anonymous‭  ·  last activity 2y ago by Anonymous‭

#2: Post edited by user avatar Anonymous‭ · 2021-09-15T09:28:27Z (over 2 years ago)
  • How to get image of contact list? I was using cursor to get contact list. Here how it looks like.
  • ```java
  • ArrayList<HashMap<String, String>> contactList = new ArrayList<>();
  • HashMap<String, String> data;
  • String name,phoneNumber;
  • Cursor c = activity.getContentResolver().query(Phone.CONTENT_URI,null,null,null,ContactsContract.Contacts.DISPLAY_NAME+" ASC ");
  • while(c.moveToNext()){
  • name = c.getString(c.getColumnIndex(Phone.DISPLAY_NAME));
  • phoneNumber = c.getString(c.getColumnIndex(Phone.NUMBER));
  • data = new HashMap<>();
  • data.put(Constants.NAME, name);
  • data.put(Constants.PHONE_NUMBER,phoneNumber);
  • contactList.add(data);
  • }
  • c.close();
  • ```
  • If you look at contact list then there will be some image. You can set a custom image if you want. Now, I want to get that image for my application? How to get that?
  • Research :
  • - I had searched for Image or Photo variable in ContactsContract.class. I had executed suspicious variable either but they weren't returning any URI or bitmap.
  • How to get image of contact list? I was using cursor to get contact list. Here how it looks like.
  • ```java
  • ArrayList<HashMap<String, String>> contactList = new ArrayList<>();
  • HashMap<String, String> data;
  • String name,phoneNumber;
  • Cursor c = activity.getContentResolver().query(Phone.CONTENT_URI,null,null,null,ContactsContract.Contacts.DISPLAY_NAME+" ASC ");
  • while(c.moveToNext()){
  • name = c.getString(c.getColumnIndex(Phone.DISPLAY_NAME));
  • phoneNumber = c.getString(c.getColumnIndex(Phone.NUMBER));
  • data = new HashMap<>();
  • data.put(Constants.NAME, name);
  • data.put(Constants.PHONE_NUMBER,phoneNumber);
  • contactList.add(data);
  • }
  • c.close();
  • ```
  • If you look at contact list then there will be some image. You can set a custom image if you want. Now, I want to get that image for my application? How to get that?
  • Research :
  • - I had searched for Image or Photo variable in ContactsContract.class. I had executed suspicious variable either but they weren't returning any URI or bitmap.
  • - I had searched in Internet also (I didn't any accurate result).
#1: Initial revision by user avatar Anonymous‭ · 2021-09-15T09:25:17Z (over 2 years ago)
Find image for contact list in Android Java
How to get image of contact list? I was using cursor to get contact list. Here how it looks like.

```java
ArrayList<HashMap<String, String>> contactList = new ArrayList<>();
        HashMap<String, String> data;
        String name,phoneNumber;
        Cursor c = activity.getContentResolver().query(Phone.CONTENT_URI,null,null,null,ContactsContract.Contacts.DISPLAY_NAME+" ASC ");

        while(c.moveToNext()){
            name = c.getString(c.getColumnIndex(Phone.DISPLAY_NAME));
            phoneNumber = c.getString(c.getColumnIndex(Phone.NUMBER));

            data = new HashMap<>();
            data.put(Constants.NAME, name);
            data.put(Constants.PHONE_NUMBER,phoneNumber);

            contactList.add(data);
        }
        c.close();
```

If you look at contact list then there will be some image. You can set a custom image if you want. Now, I want to get that image for my application? How to get that?

Research : 

- I had searched for Image or Photo variable in ContactsContract.class. I had executed suspicious variable either but they weren't returning any URI or bitmap.