contacts

Android getContentResolver().query error

走远了吗. 提交于 2019-12-25 03:15:36
问题 I'm rather new to both Java programming and to Android development, so my learning curve is rather steep at the moment. I seem to be stuck on something that I can't find decent examples for how to work past it. I wrote a function that gets all my phone's contacts based on examples and docs I found here & there online. The problem I cannot seem to work through is this. The following code works just fine; private void fillData() { // This goes and gets all the contacts // TODO: Find a way to

How TIMES_CONTACTED works on Android

若如初见. 提交于 2019-12-25 01:55:48
问题 I try an application that simply makes a list of contact with same information (name, number, last contact, etc.) order by ContactsContract.CommonDataKinds.Phone.TIMES_CONTACTED. But the values are wrong, I have 481 calls to a number I never call and 0/10 calls to the number I call most frequently. Tha phone is a HTC Legend. Are there problems with this value? 回答1: From a quick look around, it seems like other users are having the same problem with both HTC and Samsung. General guesswork

Sync device contact list with Firebase using MVVM (Android Architecture Components)

橙三吉。 提交于 2019-12-24 21:26:47
问题 I've always used the structure below to identify whether a user has an account in my app. All of this code is placed in MainActivity , but Google Architecture Components suggests to separate UI from the back-end logic. I've followed the example below for integrating the contact list with MVVM structure. https://github.com/NaarGes/Android-Contact-List But I don't know how to insert the Firebase Realtime Database validation. private void getContactList(){ Cursor phones = getContext()

How to insert 'profile' contact programmatically in Android?

白昼怎懂夜的黑 提交于 2019-12-24 12:23:02
问题 I'm building an app that accesses a users 'Profile' contact on Android. However, there are some cases where the user may not have a 'Profile' contact set up. In this case, I would like to programatically insert the profile contact. However, I am unable to achieve this. Here is my code so far: ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int rawContactInsertIndex = ops.size(); ops.add(ContentProviderOperation.newUpdate(ContactsContract.Profile.CONTENT

Why is onActivityResult is called before a contact is chosen?

瘦欲@ 提交于 2019-12-24 11:28:31
问题 I'm following the answer https://stackoverflow.com/a/867828/129805 to add a contact picker to my app. The problem is that onActivityResult is immediately invoked with the correct reqCode ( PICK_CONTACT ), but with a resultCode of 0 and a null for data. It is not invoked again, when the user actually picks a contact. The AndroidManifest gives this activity android:launchMode="singleInstance"> as I only ever want there to be one instance. What have I done wrong? MainActivity.java: @Override

How can I determine that CNContact is is favorites? [duplicate]

主宰稳场 提交于 2019-12-24 07:24:02
问题 This question already has answers here : Find Favorite contacts from the iOS Address Book API (3 answers) Closed last year . My iOS application fetches contacts from device using code [[CNContactStore new] requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError *error) { if (granted) { NSArray *keys = @[CNContactNamePrefixKey, CNContactGivenNameKey, CNContactMiddleNameKey, CNContactFamilyNameKey, // ... NSString *containerId = store.defaultContainerIdentifier

when adding contacts to sim card, they are only displayed after rebooting the device

五迷三道 提交于 2019-12-24 04:48:13
问题 I am trying to add contacts to SIM Card, they seem to be added to the SIM Card but they're only visible after rebooting the device (even to the native People app).. Here is the code I'm using: final Uri uri = Uri.parse("content://icc/adn"); ContentValues mContentValue = new ContentValues(); mContentValue.put("tag", contactName); mContentValue.put("number", contactNumber); getContentResolver().insert(uri, mContentValue); is it a problem with sync'ing the contacts db after creating the contacts

Getting newly inserted contacts in Android

好久不见. 提交于 2019-12-24 03:43:16
问题 In my application, I'm extracting all the contacts and upload them to the server. But there's a problem. I know how to extract all the contacts, but is there any way to get the newest contacts? For example: The first time I open the app, I upload all the contacts but the other times I don't want to upload all of them, just the newest. Do you know any way to do it? Thanks! 回答1: If your contacts have some order (by ID, by Name), you can save the identifier of the last contact you saved and the

android contacts provider: how to set phone number primary

眉间皱痕 提交于 2019-12-23 17:15:59
问题 How to set a contact's phone number to be primary number when adding or updating a contact building a custom contacts provider. The adding and updating of contacts is working fine but I don't know how to set one number of the contact to be primary, or default number. 回答1: mValues.put(Phone.IS_PRIMARY, 1); mValues.put(Phone.IS_SUPER_PRIMARY, 1); Both Phone.IS_PRIMARY and Phone.IS_SUPER_PRIMARY have to be set. 回答2: I had the same problem, my solution is: ContentProviderOperation.Builder bld =

querying contacts - SOMETIMES returns empty cursor

自古美人都是妖i 提交于 2019-12-23 12:16:17
问题 I'm trying to query contact's display name: @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQ_CODE_PICK_CONTACT: if (resultCode == Activity.RESULT_OK) { Uri contactUri = data.getData(); ContentResolver cr = getActivity().getContentResolver(); Cursor c = cr.query(contactUri, null, null, null, null); if (c != null && c.moveToFirst()) { //get the contact name } } break; } } Now here is the problem: For some contacts the cursor