android-contacts

How to query all contacts that belong to an account?

纵饮孤独 提交于 2019-12-06 02:11:50
问题 Background Contacts on the address book can have an account data that's attached to them. Each app can have an account, and then add its own information for the contact. Apps such as Telegram, WhatsApp, Viber,... - all create an account that adds information and/or actions to contacts. Here's an example of a contact that has both WhatsApp and Viber accounts for it: The problem I'm trying to figure out how to fetch all contacts that have a specified account. Since WhatsApp is the most popular

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

删除回忆录丶 提交于 2019-12-06 01:44:17
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 help will be highly appreciated. Amokrane Chentir The code in the documentation is related to how to

Insert RawContact with a specific contactid

◇◆丶佛笑我妖孽 提交于 2019-12-06 01:42:23
I am trying to create a rawcontact in android that has a specific contact id, so it is linked to other rawcontacts with the same contactid (not rawcontactid). The problem is I am unable to insert the Contact_ID into the ContentProviderOpertations. Using the following code return "Insert failed" ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int id = (int) contactId; String condition = Data.RAW_CONTACT_ID + "=?"; String[] parameters = { "" + id }; try { String accountName = account.name; String accountType = account.type; ops.add(ContentProviderOperation

how to select unique contacts from android

a 夏天 提交于 2019-12-06 00:54:21
问题 i want to select unique contacts from android only that contacts which have phone numbers. i am using this code ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, ContactsContract.Contacts.DISPLAY_NAME); // Find the ListView resource. mainListView = (ListView) findViewById(R.id.mainListView); // When item is tapped, toggle checked properties of CheckBox and // Planet. mainListView .setOnItemClickListener(new AdapterView

People API of google versus contacts API

自古美人都是妖i 提交于 2019-12-05 10:43:10
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(tokenResponse.getAccessToken()) .setAlt("json") .setRequestMaskIncludeField("person.names,person

Android: get contact id after insert

故事扮演 提交于 2019-12-05 09:59:05
I need to store the contact id value after create a new contact, in order to be able to reference it in other moment. For example, I create a new contact, and after that I want to delete it from its contact id, so I need to retrieve the contact id value after create a new contact. This is how I create new contacts: ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI).withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, tipoCuenta).withValue(ContactsContract.RawContacts.ACCOUNT

Android: Directory data provider for PhoneLookup

China☆狼群 提交于 2019-12-05 07:26:55
I'm writing a custom Android contacts directory, I have implemented the ContactsContract.Directory provider and the search from within the phone app works fine. The problem I am facing now is that when I have an incoming/outgoing call the Android dialer does not query the custom directory I registered. Is it possible to partake in caller ID resolution via PhoneLookup or some other way? Also as a possible workaround I have tried implementing an outgoing/incoming call interceptor with BroadcastReceiver but I see no way of returning the contact data to the dialer. The only option I have found for

Displaying contacts only with phone numbers using ACTION_PICK intent in Android device

你说的曾经没有我的故事 提交于 2019-12-05 04:04:38
My goal is to only display contacts with phone number to user and let user select few contacts which I want to store locally. I have used various options in place of ContactsContract.Contacts.CONTENT_URI in below method. But I am getting lot many of the contacts (many are junk with only email ids) displayed. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.contact_selector); ((Button)findViewById(R.id.btnphonecontactlist)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method

How to add contacts programmatically in Android?

試著忘記壹切 提交于 2019-12-05 02:39:39
问题 I have tried this but Contacts were not added! ContentResolver cr = this.getContentResolver(); ContentValues cv = new ContentValues(); cv.put(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, "sai1"); cv.put(ContactsContract.CommonDataKinds.Phone.NUMBER, "9640954335"); cv.put(ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE); cr.insert(ContactsContract.RawContacts.CONTENT_URI, cv); 回答1: Try to use following code ArrayList

Fetch contact photo in android gives null

女生的网名这么多〃 提交于 2019-12-05 02:06:14
问题 I want to fetch the photo of the contact while a user enters number.By using phone number i am getting users name but for image it shows null. my code is following : public class NewtempActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageView img = (ImageView) findViewById(R.id.imageView1); final EditText edit = (EditText) findViewById(R.id.editText1); TextView txt = (TextView)