Skip to content

Jagerfield/Mobile-Contacts-Library

Repository files navigation

Mobile Contacts Library

This application demonstrates the "MobileContactsLib", The library uses the "ContentResolver", it is a well structured, fast, easy to use and easy to modify library for getting contacts from the mobile. This library requires minimum SDK 15.

Images from the app:

 

The demo app for this library is available on Google Play:

Get it on Google Play

Installation

In the app manifest file add this permission:

<uses-permission android:name="android.permission.READ_CONTACTS" />

In the app build.gradle add the following:

a. Add JitPack repository at the end of repositories

    repositories {
      maven { url 'https://jitpack.io' }
    }

b. Then add this dependency

    dependencies {
	        compile 'com.github.Jagerfield:Mobile-Contacts-Library:v1.7'
	}

How to use?

There are two ways to implement this library, the first method is to directly implement it on the main-thread. The library is fast and I didn't ntice any delays.

  1. After instaling the library, declare and instantiate an object of type "ImportContacts" class with "context" as an argument.
  2. Call the getContacts() method to get all the contacts.
  /**
   * Declare and instantiate an object of the "ImportContacts" class
   */
    ImportContacts importContacts = new ImportContacts(context);

  /**
   * Fetch mobile contacts list
   */
    ArrayList<Contact> listItem = importContacts.getContacts();   

From version 1.7, you can fetch contacts through an Async call.

  new ImportContactsAsync(activity, new ImportContactsAsync.ICallback()
          {
              @Override
              public void mobileContacts(ArrayList<Contact> contactList)
              {
                  //Your code here
              }
          }).execute();

Available Contact elements:

1. Name: 
  a. Displaydname
  b. Firstname
  c. Lastname
2. Nickname: 
  a. Nickname
  b. Nicknametype
3. Number: 
  a. Number
  b. Normalizednumber
  c. Numbertype
4. Email: 
  a. Email
  b. Emaillabel
  c. Emailtype
5. Website:
  a. Website
6. Event:
  a. Eventstartdate
  b. Eventlabel
  c. Eventtype
7. Note:
  a. Note
8. Address:
  a. Address
  b. Addresstype

UML Diagram

This is a general diagram of the library's architectural design, and it only includes the numbers elements for clarity.

Apps using the library

A version of this library is used in Data & Contacts Sharing Mgr

Get it on Google Play

The Mobile Contact Library uses the Android Utilities Library to manage permissions:

Android Utilities Library   Get it on Google Play

Privacy Policy

This app sample will request the follwoing permission below which require user approval and is used for demonstration purposes only. No data is shared or used outside this app.

  • android.permission.READ_CONTACTS

About

A well structured, and fast library for getting contacts from the mobile.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages