android-contacts

How to filter a contact picker intent on the basis of account type

大憨熊 提交于 2019-12-04 12:14:54
On applying a picker (implicit) intent, we can show the contacts list , with all the contacts present in the phone. For this we usually use below code : Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI); startActivityForResult(contactPickerIntent, RESULT_PICK_CONTACT); But what should be done to filter the contacts displayed in the list as per the Account Types . For e.g- if I want to show only the contacts which are registered with whatsapp. What shall be done in this case scenario to show only the whats app registered contacts in

Android API 8 , 10 ContactsContract.Data.HAS_PHONE_NUMBER no such column

折月煮酒 提交于 2019-12-04 11:06:57
The below query runs fine on my device (API 15). It does not work in my emulator running API 8 or API 10. Here is the query: Cursor contactsCur = getContentResolver().query( ContactsContract.Data.CONTENT_URI, new String[] { ContactsContract.Data._ID, ContactsContract.Data.CONTACT_ID, ContactsContract.Data.DISPLAY_NAME, ContactsContract.CommonDataKinds.Organization.COMPANY, ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.Data.LOOKUP_KEY, ContactsContract.CommonDataKinds.Phone.NUMBER, Contacts.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.MIMETYPE, ContactsContract

ContentObserver for listening contact changes

好久不见. 提交于 2019-12-04 10:40:41
问题 I really don't understand why content observer listens the changes which is not related with the contact info. I simply registered to the URI which I wanna listen the changes: getContentResolver().registerContentObserver(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, true, contactsObserver); But after calling someone or texting to someone, it triggers and calls onChange method in ContentObserver. So I need to re-sync all the contact list with my application although I don't need to do.

Android. to display contacts as list view

China☆狼群 提交于 2019-12-04 10:38:17
问题 I want to display contacts in list view and add actions on all contacts , like on click on a particular contact it should display the phone number , mail id and delete of the particular contact... import android.app.ListActivity; import android.content.ContentResolver; import android.database.Cursor; import android.os.Bundle; import android.provider.ContactsContract; import android.view.Menu; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; import

How to create a contact programmatically [duplicate]

风流意气都作罢 提交于 2019-12-04 08:42:43
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to add new contacts in android public boolean createContact(String name, String number, String email) { boolean success = true; try { ContentValues contentValues = new ContentValues(); ContentResolver contentResolver = getContentResolver(); contentValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); contentValues.put(Phone.NUMBER, "123254"); Uri uri = contentResolver.insert(android.provider.ContactsContract

How to query all contacts that belong to an account?

百般思念 提交于 2019-12-04 07:10:37
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 that I know of, my tests focus on it. My problem is that some users claim what I did barely returns

how to select unique contacts from android

隐身守侯 提交于 2019-12-04 05:53:49
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.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View item, int position, long id)

Android contacts custom field

半城伤御伤魂 提交于 2019-12-04 04:42:58
问题 Is it possible to add custom field to some contacts, with custom mimetype (like facebook profile) without writing sync adapter, authenticator and sync service? I do not want to add "synchronization" functionality for my application. 回答1: After long research I think that I found an answer to this question. There is no way of creating custom clickable and visible fields without writing some Synchronization service code, authenticator and syncAdapter. Here is sample code which is adding new

How to delete sim card contact in android

别说谁变了你拦得住时间么 提交于 2019-12-03 22:53:25
问题 below is my code for delete contact from phone Uri contactUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phone)); Cursor cur = mContext.getContentResolver().query(contactUri, null, null, null, null); boolean flag = false; try { if (cur.moveToFirst()) { do { if (cur.getString( cur.getColumnIndex(PhoneLookup.DISPLAY_NAME)) .equalsIgnoreCase(name)) { String lookupKey = cur .getString(cur .getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); Uri uri = Uri.withAppendedPath

permission.READ_CONTACTS does not seem to work

好久不见. 提交于 2019-12-03 22:50:04
I'm working on a simple app that browses through the user's contacts. Unfortunately I keep getting the following error: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.HtcContactsProvider2 uri content://com.android.contacts/contacts from pid=27455, uid=10171 requires android.permission.READ_CONTACTS My manifest file looks like this: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.helloMaps" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8"