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
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...
#2: Post edited
- 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
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.