contactscontract

Android Launching Contacts Application

社会主义新天地 提交于 2019-11-29 12:55:06
I wanna launch the Contacts application from my application Activity. I am not able to understand how to do it. Button contact = (Button) findViewById(R.id.contact); contact.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { Intent i4 = new Intent(); i4.setAction(Intent.ACTION_VIEW); i4.addCategory(Intent.CATEGORY_DEFAULT); i4.setType("vnd.android.cursor.dir/phone"); startActivity(i4); } }); Error: void showContacts() { Intent i = new Intent(); i.setComponent(new ComponentName("com.android.contacts", "com.android.contacts.DialtactsContactsEntryActivity")); i

Edit name/phone number of contact programmatically

喜欢而已 提交于 2019-11-29 10:07:26
I am trying to modify displayed name of a contact programmatically: try { ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) .withSelection(ContactsContract.CommonDataKinds.Phone._ID + " = ?", new String[] {contact_id}) .withValue(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, "anything") .build()); ContentProviderResult[] result = getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); } catch (Exception e) { Log.w("UpdateContact", e.getMessage()+""); for(StackTraceElement ste : e

Get Postal address from a contact using ContactsContract api on android

好久不见. 提交于 2019-11-29 05:07:09
I am using ContactsContract api intent for showing all contacts from an activity. This intent returns an id of the contact. I need to get the postal address of this contact. Here is the code which i am using for showing contacts: Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); startActivityForResult(intent, PICK_CONTACT); I am getting the result in the onActivityResult function. Please help, how do i do this. in your onActivityResult, first get the contact ID and query the ContactsContract.Data for the relevant data: // get the contact ID

Cannot retrieve email from Contacts

五迷三道 提交于 2019-11-28 14:33:10
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.getString(phones.getColumnIndex(ContactsContract.Contacts._ID)); String name=phones.getString(phones

Access email-id along with name and phone number from contact list in Android

让人想犯罪 __ 提交于 2019-11-28 12:35:17
问题 Here I am accessing name and phone number from mobile and uploading to server. I am not facing any problem in this. I have made some modifications to access email also. But I am not able to fetch the email. In place of email it is displaying phone number. I have used System.out.print to check the details. Here is my code. DisplayContact public class DisplayContact extends Activity implements OnItemClickListener{ //ArrayList to store name and phone number List<String> name1 = new ArrayList

How to show sync failed message

一曲冷凌霜 提交于 2019-11-28 05:34:36
问题 I've build a contacts sync adapter. It's all working fine but I need one more thing. If for some reason the sync does not complete successfully, I want to show a message like Google account is showing when the sync fails 回答1: The solution was to set the delay on the sync result. After this delay the sync will be restarted. try { DO THE SYNCHRONIZATION } catch (AuthenticationException e) { Log.e(TAG, "AuthenticationException"); syncResult.stats.numAuthExceptions++; syncResult.delayUntil = 180;

How to get Contact ID, Email, Phone number in one SQLite query ? Contacts Android Optimization

耗尽温柔 提交于 2019-11-28 04:11:34
I want to fetch All Contacts atleast with one phone Number, also I want all Phone Numbers and All emails for every Contact. Current code : // To get All Contacts having atleast one phone number. Uri uri = ContactsContract.Contacts.CONTENT_URI; String selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + " > ?"; String[] selectionArgs = new String[] {"0"}; Cursor cu = applicationContext.getContentResolver().query(uri, null, selection, selectionArgs, null); // For getting All Phone Numbers and Emails further queries : while(cu.moveToNext()){ String id = cu.getString(cu.getColumnIndex

Edit name/phone number of contact programmatically

旧时模样 提交于 2019-11-28 03:21:54
问题 I am trying to modify displayed name of a contact programmatically: try { ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) .withSelection(ContactsContract.CommonDataKinds.Phone._ID + " = ?", new String[] {contact_id}) .withValue(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, "anything") .build()); ContentProviderResult[] result = getContentResolver().applyBatch(ContactsContract.AUTHORITY,

MultiAutoCompleteTextView with contacts phone numbers

放肆的年华 提交于 2019-11-28 02:17:34
I need to create a MultiAutoCompleteTextView with the phone numbers of the contacts on a user's device. What I need is similar to gmail; except with gmail email addresses are used. For the contacts, I have the following needs: each phone number must be an entry. So if John has 3 numbers (home, cell, work), they show as 3 entries each entry is searchable by phone number or by first/last name of person To create my adapter, I try to modify the one provided by Google but when I download the sample, it does not compile (kind of a crappy experience when the thing is right out of the box, but I am

Cannot insert android contacts programmatically into android device

大憨熊 提交于 2019-11-27 22:19:37
问题 ArrayList<ContentProviderOperation> ops =new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) .withValue(Data.RAW_CONTACT_ID, 3) .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) .withValue(Phone.NUMBER, "999999999") .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) .withValue(Phone.DISPLAY_NAME, "hhhhhhh") .withValue(ContactsContract.CommonDataKinds.Email.DATA, "abcd@gmail.com") .build()); ops.add(ContentProviderOperation.newInsert