android-contacts

How to import or insert contacts from .vcf file in Android programmatically?

喜夏-厌秋 提交于 2019-12-01 05:45:55
问题 I create .vcf file of all contacts in Android using below code. public static void getVCF() { final String vfile = "POContactsRestore.vcf"; Cursor phones = mContext.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); phones.moveToFirst(); for(int i =0;i<phones.getCount();i++) { String lookupKey = phones.getString(phones.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT

getting contacts from a specified group in android

怎甘沉沦 提交于 2019-12-01 05:31:20
问题 I'm trying to get contacts from a specific group of known id.i'm able to get group id and contact names in that group.but i'm unable to get contact numbers.tried some solutions from google search, but every time i'm getting phone number same as group id , if i query group for phone numbers and contact names using Phone.number , Phone.DISPLAY_NAME.if i use below method i'm getting error please help me to figure out whats wrong in my code. Code : protected void onCreate(Bundle

Obtaining phone number from lookup URI

[亡魂溺海] 提交于 2019-12-01 04:48:30
I've been trying to obtain a contact's phone number using their lookup URI, but I'm not getting it to work. Cursor myC = getContentResolver().query(lookupURI, null, null, null, null); String phoneNumber; if (myC.moveToFirst()) { while (myC.moveToNext()) { phoneNumber = myC.getString(myC .getColumnIndex(Phone.NUMBER)); Log.v("t", "phone number is: " + phoneNumber); } } where lookupURI.toString() is this URI: content://com.android.contacts/contacts/lookup/0r1-304846522C3052482C4A3442423C3248/1 Anyone knows what I'm doing wrong? Can't guarantee this'll work for 4.0 because I haven't used it in a

Android - How to get a contact from call log?

别来无恙 提交于 2019-12-01 04:29:23
I am trying to get contacts from call log. I can get the contact numbers from main contacts using this code : public void getContacts(View view) { Intent intentContact = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intentContact, 0); } public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { try { to.setText(getContactInfo(intent)); } catch(NullPointerException e) { // Do nothing ;) } } } protected String getContactInfo(Intent intent) { String phoneNumber = to.getText().toString(); Cursor cursor =

Android 6.0 (Marshmallow) READ_CONTACTS permission allows to read Contact's name when permission is denied

怎甘沉沦 提交于 2019-12-01 03:47:16
I want to check how new permission model works so in app's settings I disable Contacts . Then I go to app and try to read Contacts and ... it kinda works: try { Uri result = data.getData(); int contentIdx; cursor = getContentResolver().query(result, null, null, null, null); contentIdx = cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER); if(cursor.moveToFirst()) { content = cursor.getInt(contentIdx); } if(content > 0) { contentIdx = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); if(cursor.moveToFirst()) { name = cursor.getString(contentIdx); } contentIdx = cursor

Obtaining phone number from lookup URI

旧街凉风 提交于 2019-12-01 02:39:56
问题 I've been trying to obtain a contact's phone number using their lookup URI, but I'm not getting it to work. Cursor myC = getContentResolver().query(lookupURI, null, null, null, null); String phoneNumber; if (myC.moveToFirst()) { while (myC.moveToNext()) { phoneNumber = myC.getString(myC .getColumnIndex(Phone.NUMBER)); Log.v("t", "phone number is: " + phoneNumber); } } where lookupURI.toString() is this URI: content://com.android.contacts/contacts/lookup/0r1-304846522C3052482C4A3442423C3248/1

Android - How to get a contact from call log?

﹥>﹥吖頭↗ 提交于 2019-12-01 01:53:17
问题 I am trying to get contacts from call log. I can get the contact numbers from main contacts using this code : public void getContacts(View view) { Intent intentContact = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intentContact, 0); } public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { try { to.setText(getContactInfo(intent)); } catch(NullPointerException e) { // Do nothing ;) } } } protected

How to display contacts in Android using AsyncTask?

≯℡__Kan透↙ 提交于 2019-12-01 01:46:15
I'm trying to list all the contacts in mobile. So far everything was working fine, but when I thought of running my code in AsyncTask I'm getting nothing on screen. Here is code snippet protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_call_list); lvCallList = (ListView) findViewById(R.id.lv_call_list); new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { pd = ProgressDialog.show(CallListActivity.this, "Loading..", "Please Wait", true, false); }// End of onPreExecute method @Override protected Void

How to display contacts in Android using AsyncTask?

淺唱寂寞╮ 提交于 2019-11-30 21:19:00
问题 I'm trying to list all the contacts in mobile. So far everything was working fine, but when I thought of running my code in AsyncTask I'm getting nothing on screen. Here is code snippet protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_call_list); lvCallList = (ListView) findViewById(R.id.lv_call_list); new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { pd = ProgressDialog.show(CallListActivity

Android Applicaiton - How to get birthday of a contact

南笙酒味 提交于 2019-11-30 17:46:43
问题 I am working on an android application for which I need to match the birthday of each contact against current date and if positive, process some business logic, which needs the complete contact details. I have found ways to read birthdays of contacts or the contacts themselves separately, but am confused as to how to combine both. Can somebody please provide some direction. Thanks 回答1: Found the answer after some looking out on the web. The way this has to be done is : Get list of contacts