android-contacts

Possible to get “Owner” contact info in Android?

半城伤御伤魂 提交于 2019-11-27 20:52:23
I haven't been able to find a straight answer on this. Can anyone tell me if it's possible to get the contact info of the phone's owner in an Android App? Daksh I have found a very easy way (got it from digging into the 4.1 Messaging app!) projection for cursor is final String[] SELF_PROJECTION = new String[] { Phone._ID,Phone.DISPLAY_NAME, }; Cursor is : Cursor cursor = activity.getContentResolver().query(Profile.CONTENT_URI, SELF_PROJECTION, null, null, null); now just do a simple cursor.moveToFirst(): and then fetch the contact id via cursor.getString(0) and the contact name via cursor

Get specific contact information from URI returned from Intent.ACTION_PICK

一世执手 提交于 2019-11-27 20:12:17
I am writing an Android app that has a data type that represents a person (specifically, the parent or guardian of a child). I'd like to be able to "import" the relevant data fields from the Contacts database in the Android device. (This should be optional; that is, it will not be a requirement that the parent/guardian is already in the Contacts database, nor will the Contacts database be updated if they add new parents/guardians.) So far, I have written code to start a new Intent to choose the specific Contact (using Intent.ACTION_PICK). I then get a URI that represents a specific Contact in

Getting Number from Contacts Picker

可紊 提交于 2019-11-27 19:33:36
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 is always the number for the contact ID BEFORE it! Example: I have 2 contacts "John Doe" and "Jane Doe"

What is the best way to get distinct contacts in Android

南笙酒味 提交于 2019-11-27 18:48:06
问题 I am successfully storing contacts in parse.com dashboard data browser by this code. public void readContacts(){ ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null); if (cur.getCount() > 0) { while (cur.moveToNext()) { String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); if (Integer.parseInt(cur.getString

How can I programmatically add a contact?

百般思念 提交于 2019-11-27 18:40:11
问题 I am trying to programmatically add a contact in Android. Here is my code: ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int rawContactInsertIndex = ops.size(); ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE,"Google") .withValue(ContactsContract.RawContacts.ACCOUNT_NAME,"user1@gmail.com") .build()); ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)

how to create custom contact list with checkbox

非 Y 不嫁゛ 提交于 2019-11-27 17:01:34
问题 how to create custom contact list with checkbox to select multiple contacts from list in android public class AddFromContacts extends Activity { ArrayList<String> listname; // ArrayList<String> list_no; Context context; LayoutInflater inflater; ListView contactlistView; String name; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.show); contactlistView = (ListView) findViewById(R.id

How to get a contact's facebook id or url from native contacts / content resolver?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 15:03:54
How to get the facebook id or url of a contacts that's been synced to the native contacts app via Facebook sync adapter? I went through different urls, but didn't see any info regarding facebook. I tried ContactsContract.Data.CONTENT_URI ContactsContract.CommonDataKinds.Email.CONTENT_URI ContactsContract.CommonDataKinds.Phone.CONTENT_URI ContactsContract.Contacts.CONTENT_URI as URIs already in the code below: Uri uri = ContactsContract.Data.CONTENT_URI; Cursor c = getContentResolver().query(uri, null, null, null, null); while (c.moveToNext()) { for (int i=0; i<c.getColumnCount(); i++) { Log.d

Fetch Contacts in android application

风流意气都作罢 提交于 2019-11-27 14:44:35
问题 I was following these links to get the contacts in my application How to call Android contacts list? http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/ I can display the list of contacts on phone but - I want to add a checkbox at each contact so that user can select multiple contacts and by clicking the done button he should be able to get all the contacts he selected Also I want to get the name of contact as well as the phone number of contact , see my code : if

How to update existing contact?

夙愿已清 提交于 2019-11-27 14:35:38
问题 I have one existing contact, I need to add a work address to that existing contact. I am using the following code, but it's not working. String selectPhone = Data.CONTACT_ID + "=? AND " + Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE + "'" + " AND " + ContactsContract.CommonDataKinds.StructuredPostal.TYPE + "=?"; String[] phoneArgs = new String[] {String.valueOf(ContactId), String.valueOf( ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK

How to listen contact inserted/updated/deleted in address book

Deadly 提交于 2019-11-27 13:46:52
问题 There are lots of questions related to it but none of them help me to get the solution. I am trying to sync all contacts from device to remote server and able to do it easily but when there is a change in contact like update/delete/insert(new contact) unable to find the solution. Tried using ContentObserver but onChange() is getting called multiple times. It's difficult to find the contact changes data. public class ContactService extends Service { private int mContactCount; @Override public