PlatformHelperContacts

@IviExperimental(reasons = [])
class PlatformHelperContacts(context: Context, account: Account? = Account(ACCOUNT_SOURCE_NAME, ACCOUNT_SOURCE_TYPE))

Util class to add and remove contacts in Android ContactsProvider using a contentResolver. Each contact added to the specified Account.

Account.name and the Account.type can be used to simulate different source of contact like for example different Bluetooth devices. If account is null the contacts will be added to the phone storage account.

Requires permission android.permission.WRITE_CONTACTS

Constructors

Link copied to clipboard
fun PlatformHelperContacts(context: Context, account: Account? = Account(ACCOUNT_SOURCE_NAME, ACCOUNT_SOURCE_TYPE))

Types

Link copied to clipboard
object Companion
Link copied to clipboard
@IviExperimental(reasons = [])
interface PlatformContactsHelperEvents : TraceEventListener

Functions

Link copied to clipboard
suspend fun addContact(prefix: String = "", firstName: String, middleName: String = "", lastName: String, suffix: String = "", asFavorite: Boolean = false, typedPhoneNumbers: List<TypedPhoneNumber>, photo: Bitmap?, companyName: String?, addresses: List<TypedAddress>?)

Add a single contact with a name, contact details and a photo. Each TypedPhoneNumber is a pair value (phone number, phone type) with a none blank phone number.

Link copied to clipboard
suspend fun deleteAllContacts()

Delete all the contacts added by this PlatformHelperContacts with the corresponding Account.name and Account.type from ContactsProvider.

Link copied to clipboard

Generate a list of Bitmaps based on a list of drawable resources.

Link copied to clipboard
suspend fun generateRandomContacts(numberOfContacts: Int, numberOfPhoneNumbers: Int, numberOfAddress: Int, photos: List<Bitmap>?, asFavorite: Boolean, contactPools: EnumSet<PlatformHelperContacts.ContactPool> = EnumSet.allOf(ContactPool::class.java), seed: Random = Random, onContactGenerated: (Int) -> Unit? = null)

Generate numberOfContacts contacts with a random name. Each contact is generated with numberOfPhoneNumbers random phone number with random phone type.