android-contacts

Android - cant get phone number of some contacts

那年仲夏 提交于 2019-12-01 12:21:54
I'm having a problem with extracting phone numbers of some people in my contact list. First I show all the contacts in a listview: String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER }; mCursor = mContext.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=?", new String[] {mContactId}, null); When clicking on an item, this is how I fetch

Save Contacts as “Phone contact”

走远了吗. 提交于 2019-12-01 11:35:16
问题 Is there way to programmatically adds the contact to the internal phone contacts book as a "phone contact"? I've tried: list.add(ContentProviderOperation .newInsert(ContactsContract.RawContacts.CONTENT_URI) .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null) .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null) .build()); with this parameters contact successfully saves to the phone, but in case i set up filter to "display phone contacts only" - created contact not appears. btw,

Android get phone contacts and remove duplicates

我的未来我决定 提交于 2019-12-01 11:27:43
I am having an issue related to contacts. I got the phone contacts and stored them in my list object. Here's the code for it Uri uri = ContactsContract.Data.CONTENT_URI; String[] projection = { ContactsContract.Data.CONTACT_ID, ContactsContract.Data.DISPLAY_NAME, ContactsContract.Data.PHOTO_ID, ContactsContract.Data.DATA1 }; Cursor phones = getContentResolver().query( uri, projection, ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND " + ContactsContract.Data.DATA1 + "!=''", null, null); if (phones.moveToFirst()) { do { long ID = phones

android - set custom ringtone to specific contact number

隐身守侯 提交于 2019-12-01 11:06:58
I am trying to develop android app, I need to assign ringtone to specific contact number without permit the user to access list of contact. here is the code for assigning ringtone to all contact : File k = new File("/sdcard/AudioRecorder", "hello.mp4"); // Uri i = data.getData(); //getDATA //String s = i.getPath(); //getPath // File k = new File(s); //set File from path //if(s!=null){ //(file.exists ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, "ring"); values.put(MediaStore.MediaColumns.MIME

In Android 7, ContentResolver's method-openAssetFileDescriptor(vCardUri, “r”) returns AssetFileDescriptor having declaredLength as -1

雨燕双飞 提交于 2019-12-01 11:04:55
In Android 7, getContentResolver().openAssetFileDescriptor(vCardUri, "r") returns AssetFileDescriptor having declaredLength as -1 returned by getDeclaredLength() . Trying to export the contacts as vcards into vcf file. The code I have tried is as follows Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey); AssetFileDescriptor fd = resolver.openAssetFileDescriptor(uri, "r"); FileInputStream fis = fd.createInputStream(); byte[] b = new byte[(int)fd.getDeclaredLength()]; fis.read(b); The above code works perfectly in Android 6 or below.But when ran using Android

In Android 7, ContentResolver's method-openAssetFileDescriptor(vCardUri, “r”) returns AssetFileDescriptor having declaredLength as -1

我怕爱的太早我们不能终老 提交于 2019-12-01 09:40:01
问题 In Android 7, getContentResolver().openAssetFileDescriptor(vCardUri, "r") returns AssetFileDescriptor having declaredLength as -1 returned by getDeclaredLength() . Trying to export the contacts as vcards into vcf file. The code I have tried is as follows Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey); AssetFileDescriptor fd = resolver.openAssetFileDescriptor(uri, "r"); FileInputStream fis = fd.createInputStream(); byte[] b = new byte[(int)fd

android - set custom ringtone to specific contact number

南楼画角 提交于 2019-12-01 09:00:29
问题 I am trying to develop android app, I need to assign ringtone to specific contact number without permit the user to access list of contact. here is the code for assigning ringtone to all contact : File k = new File("/sdcard/AudioRecorder", "hello.mp4"); // Uri i = data.getData(); //getDATA //String s = i.getPath(); //getPath // File k = new File(s); //set File from path //if(s!=null){ //(file.exists ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k

Android get phone contacts and remove duplicates

雨燕双飞 提交于 2019-12-01 07:55:05
问题 I am having an issue related to contacts. I got the phone contacts and stored them in my list object. Here's the code for it Uri uri = ContactsContract.Data.CONTENT_URI; String[] projection = { ContactsContract.Data.CONTACT_ID, ContactsContract.Data.DISPLAY_NAME, ContactsContract.Data.PHOTO_ID, ContactsContract.Data.DATA1 }; Cursor phones = getContentResolver().query( uri, projection, ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND " +

getting contacts from a specified group in android

℡╲_俬逩灬. 提交于 2019-12-01 07:03:03
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 savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.group_contacts); addGroups = (Button)

Android - Retrieve Contact Photo and Display

只谈情不闲聊 提交于 2019-12-01 06:12:20
问题 I am creating a simple application that retrieves the name and phone number of each individual contact and display in a list view along with the contact's photo in a thumbnail sized image-view at the beginning of the row. I have managed to retrieve and display the name and number but have failed at getting the photo to display after going through many tutorials and stacks. I eventually rolled it back to just displaying the name and number. Can anyone help with the contact photo, I have