android-contacts

How to use SHOW_OR_CREATE_CONTACT and also set a photo for the contact?

十年热恋 提交于 2019-12-08 06:52:47
问题 Background I know that there are various fields that can be set via this intent, such as address, phone numbers, name, etc... : final Intent intent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, Uri.parse("tel:" +PhoneNumberService.formatNumber(phoneNumber, PhoneNumberFormat.NATIONAL)); intent.putExtra(ContactsContract.Intents.Insert.NAME, name); intent.putExtra(ContactsContract.Intents.Insert.POSTAL_ISPRIMARY,address); intent.putExtra(ContactsContract.Intents.Insert.POSTAL

PhoneLookup.CONTENT_FILTER_URI returns twice the same contact

跟風遠走 提交于 2019-12-08 05:22:50
问题 in my code below, i am trying to get all contacts with a specific phone number. however it looks like i always get some of the contacts id more then once. specifically i have 2 contacts with the same phone number, and i get 3 contact Id's. one of them twice (the same ID) any ideas? thanks Cursor contactLookupCursor = localContentResolver.query( Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(requestedPhone)), new String[] {PhoneLookup._ID}, null, null, null); if

How to use SHOW_OR_CREATE_CONTACT and also set a photo for the contact?

浪子不回头ぞ 提交于 2019-12-08 04:57:28
Background I know that there are various fields that can be set via this intent, such as address, phone numbers, name, etc... : final Intent intent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, Uri.parse("tel:" +PhoneNumberService.formatNumber(phoneNumber, PhoneNumberFormat.NATIONAL)); intent.putExtra(ContactsContract.Intents.Insert.NAME, name); intent.putExtra(ContactsContract.Intents.Insert.POSTAL_ISPRIMARY,address); intent.putExtra(ContactsContract.Intents.Insert.POSTAL,address); ... //other stuff, like on this post: http://stackoverflow.com/q/3456319/878126 The problem I'd

Contacts - how to distinguish between SIM, phone and other contacts?

只愿长相守 提交于 2019-12-08 03:20:42
问题 I'm reading ALL contacts from the phone like following: Cursor cursor = MainApp.get().getContentResolver().query( ContactsContract.Data.CONTENT_URI, null, null, null, ContactsContract.Data.CONTACT_ID + " ASC"); I read ContactsContract.Data.ACCOUNT_TYPE_AND_DATA_SET and ContactsContract.RawContacts.ACCOUNT_NAME from the contacts and analysed them because I want to distinguish between phone, sim and any other contact... But I only can see that the values are very phone specific. 1) I currently

Update multiple phone numbers in contact

╄→尐↘猪︶ㄣ 提交于 2019-12-07 19:03:34
问题 I am tried to update multiple phone numbers of specific contact using following code: for(int j=0;j<allPhoneNumbersLength;j++) { PhoneInfo phoneInfo = (PhoneInfo) allPhoneNumbers.elementAt(j); String phoneValue = phoneInfo.getValue(); int phoneType = phoneInfo.getIndex(); // phoneType = Phone.TYPE_HOME, Phone.TYPE_WORK, etc ContentProviderOperation.Builder builderPhone = ContentProviderOperation.newUpdate(Data.CONTENT_URI) .withSelection(ContactsContract.Data.CONTACT_ID + "=?"+" AND "

update contact name & number in android programmatically

时光毁灭记忆、已成空白 提交于 2019-12-07 16:26:39
问题 I create an Application to Read, Update, Delete Contacts Details. Here is a problem to updating Contact name and number.Could anyone help me please how can I do that. I am using the following code, but it's not working. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_fragment_edit, container, false); textView = (TextView) view.findViewById(R.id.tvnew1); imageView = (ImageView)

how to get contacts type in android?

懵懂的女人 提交于 2019-12-07 15:39:14
问题 I want to retrieve both contacts name and their type in my layout.I am providing my activities and layout file.I am getting an invalid column type exception.any help would be greatly appreciable.thanks in advance. TestActivity.class: package application.test; import android.app.ListActivity; import android.os.Bundle; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Data; import android.view

How to obtain 'lookup key" in Android Contacts API?

陌路散爱 提交于 2019-12-07 14:58:49
问题 Following is from Android Documentation You can acquire a lookup key from the contact itself, it is a column on the ContactsContract.Contacts table. Uri lookupUri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey) Cursor c = getContentResolver().query(lookupUri, new String[]{Contacts.DISPLAY_NAME}, ...); try { c.moveToFirst(); String displayName = c.getString(0); } finally { c.close(); } but couldn't get it to work. I visited answers on Stackoverflow here and here but in vein. Any

Getting all contacts as vcard in Android

别来无恙 提交于 2019-12-07 13:45:17
问题 I'm trying to get all of my contacts as vCard. So this is my code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if (cur.getCount() > 0) { //cur.moveToFirst(); while (cur.moveToNext()) { try{ String lookupKey = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); Uri uri = Uri

People API of google versus contacts API

有些话、适合烂在心里 提交于 2019-12-07 05:06:09
问题 While trying to fetch contacts using google account of user , I am facing some issues after using people API.It only returns few email addresses out of all listed ones.Access token and all scopes have been set correctly. Code for following : People peopleService = new People.Builder(httpTransport, jsonFactory, credential) .build(); ListConnectionsResponse response = peopleService.people().connections().list("people/me") .setPageSize(500).setSortOrder("FIRST_NAME_ASCENDING") .setAccessToken