android-contacts

How does apps like whatsapp show contacts that are only using the app?

偶尔善良 提交于 2019-12-10 10:49:07
问题 In apps that use phone authentication like whatsapp: When any user opens to check his/her contacts, whatsapp will show only the contacts from your phone that are using whatsapp (like they filter your contacts). My thoughts on implementing something similar: I can save all users in a database (when they authenticate with my app), now when I load contacts in an activity I check to see if the contact exist in the database, and if the user exist then I add him/her to the list. Problem: If I used

Duplicate entries when fetching contacts groups Android 4+

大憨熊 提交于 2019-12-10 10:40:24
问题 I am fetching all the contact groups using the following query: //get list of contact groups from ContactsContract Cursor groups_cursor = getContentResolver()// .query(ContactsContract.Groups.CONTENT_SUMMARY_URI,// new String[] { // ContactsContract.Groups._ID,// ContactsContract.Groups.TITLE, // ContactsContract.Groups.DATA_SET,// ContactsContract.Groups.GROUP_VISIBLE,// ContactsContract.Groups.DELETED,// ContactsContract.Groups.SYSTEM_ID,// ContactsContract.Groups.SUMMARY_COUNT, //

How to filter a contact picker intent on the basis of account type

时光怂恿深爱的人放手 提交于 2019-12-09 20:36:55
问题 On applying a picker (implicit) intent, we can show the contacts list , with all the contacts present in the phone. For this we usually use below code : Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI); startActivityForResult(contactPickerIntent, RESULT_PICK_CONTACT); But what should be done to filter the contacts displayed in the list as per the Account Types . For e.g- if I want to show only the contacts which are registered

Using CursorLoader to get emails causes duplication of emails

六月ゝ 毕业季﹏ 提交于 2019-12-09 09:18:36
问题 I am trying to get email ids of uses contacts. For that I am using Cursor Loader. There is one problem I am getting duplicate email ids also. How to remove email duplicacy. Should I use raw query "SELECT DISTINCT" instead of using CursorLoader or there is some other solution? @Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Email

How to show custom type contact inside Contact like WhatsApp android

*爱你&永不变心* 提交于 2019-12-09 06:31:15
问题 /** * Account type id */ public static final String ACCOUNT_TYPE = "com.test.app"; /** * Account name */ public static final String ACCOUNT_NAME = "Test"; public static void addContact(Context context, User contact) { ContentResolver resolver = context.getContentResolver(); resolver.delete(RawContacts.CONTENT_URI, RawContacts.ACCOUNT_TYPE + " = ?", new String[] { AccountConstants.ACCOUNT_TYPE }); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add

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

寵の児 提交于 2019-12-09 03:09:01
问题 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

Get Android contacts with type-to-filter functionality, restricted to a specific account

荒凉一梦 提交于 2019-12-08 19:11:58
问题 I'm trying to: Display a list of contacts Let the user search through them by typing a query Limit search results only to a specific Google/Gmail account. This is how I build the URI for the cursor: // User is searching for 'jo' String query = "jo"; Uri uri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(query)); // Restrict the query to contacts from 'example@gmail.com' Uri.Builder builder = uri.buildUpon(); builder.appendQueryParameter( ContactsContract.DIRECTORY_PARAM_KEY,

Add new contact via intent with multiple phone numbers

吃可爱长大的小学妹 提交于 2019-12-08 18:55:03
问题 I want to add a new contact using ContactsContract.Intents.Insert . But the problem is that I don't know how many phone numbers can be. And as I understand I can pass only three phone numbers using PHONE , SECONDARY_PHONE , TERTIARY_PHONE constants. Is there any way to pass more than three numbers? 回答1: Found a solution. It consists in using ContentValues: Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); ArrayList<ContentValues> data =

How to add Android Contacts into a listview with a check box [duplicate]

眉间皱痕 提交于 2019-12-08 07:44:54
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How do I link a checkbox for every contact in populated listview? i m a beginner in android . i want to get the phone contacts and then put them into a listview with a checkbox so that user can select more then one contact and then get the selected contacts. is there any tutorial for that???? thanks 回答1: here is the code to get all contacts with checkbox : ContentResolver cr = getContentResolver(); Cursor cur =

Show my app icon infront off contact

允我心安 提交于 2019-12-08 07:26:16
问题 As in WhatsApp , if you click on a name to call, down the list you will find the WhatsApp logo in front of the number if you want to txt using WhatsApp . Can we add the easyPhoneCard in that list, so the user can directly call using that option without clicking on the prompt to call. 回答1: You have to add in your manifest some rules. In that way, Android will be able to list your application as compatible with a specific action (here is call action) I think it will be something like <intent