android-contacts

Can I perform this Android query with ContentResolver.query()? (LEFT JOIN and CASE)

∥☆過路亽.° 提交于 2019-11-27 12:25:54
I am looking to perform the following query (in pseudo-code) on Android: SELECT C.ID, C.NAME, CASE ISNULL(G.GROUPID,0) = 0 THEN 0 ELSE 1 END INGROUP FROM CONTACTS C LEFT JOIN GROUPMEMBERSHIP G ON G.CONTACTID = C.ID AND G.GROUPID = ? I am looking to select the ID and Name of ALL contacts in the system address book, via the default Contacts ContentProvider, along with a 0/1 field indicating whether the contact is a member of group ? . I could of course get all contacts easily enough, then loop through and query the membership separately easy enough in my Adapter class, but I'd imagine performing

Android get all contacts telephone number in ArrayList

怎甘沉沦 提交于 2019-11-27 12:05:19
I am trying to save all contacts telephone numbers in an ArrayList but I cant find a way how. Is there a way to get them instead of picking them one by one with ContactsContract? Santhosh ContentResolver cr = mContext.getContentResolver(); //Activity/Application android.content.Context Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if(cursor.moveToFirst()) { ArrayList<String> alContacts = new ArrayList<String>(); do { String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); if(Integer.parseInt(cursor.getString(cursor

Accessing Android Contact Group Names

為{幸葍}努か 提交于 2019-11-27 11:22:57
问题 Can you please tell me how to fetch contact groups programmatically stored in our android phone? 回答1: final String[] GROUP_PROJECTION = new String[] { ContactsContract.Groups._ID, ContactsContract.Groups.TITLE }; cursor = getContentResolver().query( ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null, null, ContactsContract.Groups.TITLE); GlobalConfig.groupList.clear(); Group g = new Group(); g.GroupIdList += "0"; g.setGroupTitle("ALL"); GlobalConfig.groupList.add(g); while (cursor

How to add whatsapp like options to contact whenever the is a new contact added to Contacts

北战南征 提交于 2019-11-27 09:07:59
I develop an app which needs to do 2 things: Create a user account (like WhatsApp). Whenever there is a new contact entry, if the contact is using my app, then immediately in the Contacts application show options "call" or "message" in the contact detail page. Example You need to create a SyncAdapter , this is basically a service that is able to sync contacts to/from a server, like Google does for Google Contacts , you can set it to be notified when a new contact is added, and have your SyncAdapter add the needed info to the contact so it'll show links to your app. If you go to your phone

Android: Retrieve Name, Phone Number, Email, Birthday from Contact

天涯浪子 提交于 2019-11-27 08:44:29
问题 I am getting only name & birthday using the code below. But I need phone number & email also. It would be great if anyone can help me out. Thanks. private void getContacts() { Uri uri = ContactsContract.Data.CONTENT_URI; String[] projection = new String[]{ ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Event.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Email.DATA, ContactsContract.CommonDataKinds.Event.START_DATE };

Cannot retrieve email from Contacts

好久不见. 提交于 2019-11-27 08:34:25
问题 I want to retrieve email,phone number and contact names from my phone-book and display them in list-view. The name and numbers are coming perfectly but the emails are not retrieving. Here is the relevant code: public void getAllContacts(ContentResolver cr) { String email=""; Cursor phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, Phone.DISPLAY_NAME + " ASC"); //email = new String[phones.getCount()]; while (phones.moveToNext()) { String id = phones

Logcat says “invalid column data1”

安稳与你 提交于 2019-11-27 07:09:54
问题 New to threading. New to SQL. New to getting Contact Info. So of course I'm lost. If I'm reading this logcat correctly, it's telling me that either: column data1 doesn't exist, or that I'm looking for the wrong info. Unfortunately, this has been a "learn from my mistakes" path of learning and I can't figure this one out. Any help is very much appreciated. The goal here is to get the Name, Phone Number, and Email of the contact (matching info by contact ID). Log: 06-22 21:15:44.700: E

Insert a new contact intent

只谈情不闲聊 提交于 2019-11-27 06:42:10
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 above code will start the contact adding form. Then when I validate it, it just asks me to open the

Broadcast on contact add/change?

假如想象 提交于 2019-11-27 04:33:46
Is there any standard broadcast intent that I can register a BroadcastReceiver for that gets triggered whenever a contact is added or changed? I've been looking through the docs for a while now but haven't found anything. Maybe it's hidden somewhere deep and one of you guys knows where. Here I go answering my own question (if anyone has a better answer, don't be shy). There's no broadcast when a contact is added/changed. However, when you look up your contacts in the RawContacts table you have a DIRTY column which is 1 if the contact was changed since the last sync, which is pretty much what I

Getting Number from Contacts Picker

时光总嘲笑我的痴心妄想 提交于 2019-11-27 04:22:45
问题 I am trying to get a contacts name and phone number after a user has picked a contact from the Contact Picker. I am attempting to make my application work for SDK v3 and up so I created an abstract class that would call only the API that I needed. I already have the abstract class working (it chooses the right API) and I also have the API for SDK v3,4 working. I am having problems getting the newer API that uses ContactsContract to work. I can get a contacts name, but the number it retrieves