android-contacts

Search contact by phone number

爱⌒轻易说出口 提交于 2019-11-26 22:06:07
In my app, user writes a phone number, and I want to find the contact name with that phone number? I usually search the contacts like this: Cursor cur = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); But I do this to access all contacts... In this app I only want to get the contact name of the given phone number... How can I restrict the query? Or do I have to go trough all contacts and see if any has the given phone number? But I believe that this can be very slow this way... Pentium10 You should have a look at the recommended ContactsContract

Android Contact Picker With Checkbox

冷暖自知 提交于 2019-11-26 20:45:42
问题 There are a lot of discussions going on about the same subject, but after spending 4 hours here, I could not find a valid description or a link to make a Contact Picker with Checkbox. I have an activity with DONE button and listview with checkbox . I have managed to show the contacts correctly. Now I want to return the selected contact phone numbers in a bundle (I think the best way) so that I can get the list of numbers in onActivityResult() . I am not sure of the way I am following is right

Inserting contacts in Android 2.2

。_饼干妹妹 提交于 2019-11-26 20:08:42
I am trying to insert new RawContact contacts, but the RawContact added doesn't get displayed when I view the contacts through Contacts or phonebook. As I understand if we create a RawContact and there is no contact associated with it then the contact will be automatically inserted. I get a valid value of rawContactId and no exceptions are thrown, so I assume the insertion is successful. Am I doing anything wrong or am I missing something? I am using the code example from developer site, just pasting it here: ContentValues values = new ContentValues(); values.put(RawContacts.ACCOUNT_TYPE,

Integrate my app with Contact

一曲冷凌霜 提交于 2019-11-26 18:12:34
问题 I would like to integrate my app with contact manager: More precisely: When I run Contact app in my phone and then I click on any avatar, a Popup (Quick Contact Badge) windows shows up with some application to choose (Contact, Mail, etc) I would like to add my Application in that place. That is possible ? I hope to be clear. Thanks in advance. 回答1: Hey guy finally I resolved this adding a custom field to ContactProvider and then QuickContactBadge will be link it for you. My code, for adding,

Android get all contacts telephone number in ArrayList

大憨熊 提交于 2019-11-26 18:09:51
问题 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? 回答1: 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

Android: Retrieve contact name from phone number

主宰稳场 提交于 2019-11-26 17:28:19
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. Pentium10 For that you need to use the optimized PhoneLookup provider as described. Add the permission to AndroidManifest.xml : <uses-permission android:name="android.permission.READ_CONTACTS"/> Then:

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

放肆的年华 提交于 2019-11-26 15:59:55
问题 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

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

心已入冬 提交于 2019-11-26 14:31:50
问题 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 回答1: 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

Broadcast on contact add/change?

为君一笑 提交于 2019-11-26 12:45:26
问题 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. 回答1: 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

How to remove a contact programmatically in android

不羁的心 提交于 2019-11-26 12:19:10
问题 I try the following code to remove contact with a specified number: private void removeContact(Context context, String phone) { //context.getContentResolver().delete(Contacts.Phones.CONTENT_URI, phone, null); context.getContentResolver().delete(Contacts.Phones.CONTENT_URI, Contacts.PhonesColumns.NUMBER+\"=?\", new String[] {phone}); } But I get this exception: java.lang.UnsupportedOperationException: Cannot delete that URL: content://contacts/phones at android.database.DatabaseUtils