android-contacts

Insert a new contact intent

微笑、不失礼 提交于 2019-11-26 12:04:14
问题 For one of my apps, I need the user to select one of his existing contacts or to create a new one. Picking one is clearly easy to do with the following code: i = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); startActivityForResult(i, PICK_CONTACT_REQUEST ); Now I want to create a new contact. I tried to use that code but it doesn\'t trigger the activity result: i = new Intent(Intent.ACTION_INSERT); i.setType(Contacts.CONTENT_TYPE); startActivityForResult(i, PICK_CONTACT_REQUEST); The

Pick a Number and Name From Contacts List in android app

扶醉桌前 提交于 2019-11-26 11:03:09
问题 i want to pick a contact with it\'s number from my contacts list. i read a lot of solutions and research for couple weeks but all of articles didn\'t work properly. some codes like following: Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intent, PICK_CONTACT); // and in activityresult: if (resultCode == Activity.RESULT_OK) { Uri contactData = data.getData(); Cursor c = managedQuery(contactData, null, null, null, null); if (c

How to get the first name and last name from Android contacts?

核能气质少年 提交于 2019-11-26 08:31:59
How to get the following fields from Android contacts? I used Android 2.2. Name prefix First name Middle name Last name Name prefix Phonetic given name Phonetic middle name Phonetic family name Look at ContactsContract.CommonDataKinds.StructuredName class. You can find there all columns you are looking for. Try sth like this: String whereName = ContactsContract.Data.MIMETYPE + " = ?"; String[] whereNameParams = new String[] { ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE }; Cursor nameCur = contentResolver.query(ContactsContract.Data.CONTENT_URI, null, whereName,

Android: Retrieve contact name from phone number

久未见 提交于 2019-11-26 05:26:24
问题 I would like to retrieve the name of a contact associated with an incoming telephone number. As I process the incoming number in the broascastreceiver having a String with the name of the incoming caller would help my project greatly. I would think this involves a query using the sql WHERE clause as a filter, but do I need to sort the contacts? An example or hint would be of great assistance. 回答1: For that you need to use the optimized PhoneLookup provider as described. Add the permission to

Read all contacts' phone numbers in android

不打扰是莪最后的温柔 提交于 2019-11-26 03:37:39
I'm using this code to retrieve all contact names and phone numbers: String[] projection = new String[] { People.NAME, People.NUMBER }; Cursor c = ctx.getContentResolver().query(People.CONTENT_URI, projection, null, null, People.NAME + " ASC"); c.moveToFirst(); int nameCol = c.getColumnIndex(People.NAME); int numCol = c.getColumnIndex(People.NUMBER); int nContacts = c.getCount(); do { // Do something } while(c.moveToNext()); However, this will only return the primary number for each contact, but I want to get the secondary numbers as well. How can i do this? You can read all of the telephone

How to get the first name and last name from Android contacts?

让人想犯罪 __ 提交于 2019-11-26 02:00:01
问题 How to get the following fields from Android contacts? I used Android 2.2. Name prefix First name Middle name Last name Name prefix Phonetic given name Phonetic middle name Phonetic family name 回答1: Look at ContactsContract.CommonDataKinds.StructuredName class. You can find there all columns you are looking for. Try sth like this: String whereName = ContactsContract.Data.MIMETYPE + " = ?"; String[] whereNameParams = new String[] { ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM