/contact-picker

Simple and lightweight contact picker library for Android - Library demonstrates use of builder pattern in kotlin. GitHub Page - https://shahbazhashmi.github.io/contact-picker/

Primary LanguageKotlinGNU General Public License v3.0GPL-3.0

contact-picker

Introduction

Contact Picker is a simple and light weight contact picker library for Android. In order to maintain its simplicity and ease of use runtime permission is not handled in the library.


Usage

  1. Create picker config object
val pickerConfig = PickerConfig.build(this@MainActivity, ({
                toolbarTitle = "Contact Picker"
                loaderColor = ContextCompat.getColor(activity, R.color.colorPrimaryDark)
                selectLimit = 5
            }))
  1. Open contact picker
ContactPicker.openPicker(this@MainActivity, pickerConfig)
  1. Listen selected contacts in onActivityResult
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        if (requestCode == ContactPicker.PICKER_REQUEST) {
            if (resultCode == Activity.RESULT_OK) {
                val list = data!!.getParcelableArrayListExtra<Contact>(ContactPicker.CONTACTS_LIST)
                Log.d("result", "got data")
            }
        }
    }

Note

  1. Grant contact permission before open conatct picker in Android 6 or above
  2. Maximum selection limit of contacts is 20