Library for Android to access and handle contacts.
- Access all contacts.
- Access contact details like all numbers(with their types).
- Access the other account details linked with contact like email, whatsapp.
- Access the recent call log with complete details.
- Various Contact Operations Add or Delete.
Steps to Implement Project
- Project Level --> build.gradle
allprojects{
repositories {
maven { url 'https://jitpack.io' }
}
}
- app level --> build.gradle
dependencies {
implementation 'com.github.abhishekborikar:contactlib:v0.1.0'
}
Usage
- Access Contacts (Names and Profile Pic)
LoadContacts contacts = new LoadContacts(getContentResolver(),getApplicationContext());
To get Contact List
final ArrayList<HashMap> contact_list = contacts.getAllContacts(R.drawable.default_contact_image);
// HashMap keys --> { "display_name", "contact_photo"}
for(HashMap item: contact_list){
String display_name = item.get("display_name");
Bitmap image = item.get("contact_photo");
}
To get Recent Call Log
final ArrayList<HashMap> recent_call_log = contacts.getRecentContacts();
// time format DD/MM/YYYY HH:MM:SS
// type --> "OUTGOING", "INCOMING", "MISSED"
// HashMap keys --> {{"display_name", "phone_number", "time","type"}
for(HashMap item: recent_call_log){
String display_name = item.get("display_name");
String number = item.get("phone_number");
String time = item.get("time");
String type = item.get("type");
}
- Access the Contact Detail Information
ContactOperation operation = new ContactOperation(getContentResolver(),getApplicationContext());
To get all the numbers
ArrayList<HashMap> contact = operation.getNumber(name);
for (HashMap item: contact) {
//All Numbers saved with their types
String number = item.get("number").toString();
String type = item.get("type").toString();
}
To get Whatsapp Number with display_name
String whatsapp_number = operation.getWhatsAppNumber(display_name);
To get Email_ID
String email = operation.getEmail(display_name);
- Modifiy Contact
Add New Contact
boolean isSaved = operation.addNewContact(display_name,phone_number);
Delete Contact
boolean isDeleted = operation.deleteContact(display_name);
Note : If any issue please post. And also if someone wants to contribute, then always welcome.