android-contacts

Retrieving a phone number with ContactsContract in Android - function doesn't work

我只是一个虾纸丫 提交于 2019-11-29 15:21:23
问题 I wrote the following function in order to retrieve one single phone number that belongs to the contact with id "contactID". The function which is to retrieve the phone number: private String getContactPhone(String contactID) { Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI; String[] projection = null; String where = ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?"; String[] selectionArgs = new String[] { contactID }; String sortOrder = null; Cursor result =

Native contact change notification

岁酱吖の 提交于 2019-11-29 14:15:45
How can I get callback in my application whenever a contact is added or deleted or changed ? Is there any standard broadcast intent that I can register a BroadcastReceiver for that ? No BroadcastReceiver available for notifying contacts changes. You may need to use ContentObserver to get notified. Lots discussions happened to here on how to receive Contacts change notification via ContentObserver. Try searching for it. Another way of getting notified, is by using SyncAdapters. Look into here for info http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-2/ 来源: https:/

Get Contact by Phone number on Android

▼魔方 西西 提交于 2019-11-29 12:53:27
I know how I can get all contacts in Android , and how to get their phone number. What I cant seem to figure out is how to get a contact by phone number... This is my current piece of code I wrote to test which phone numbers are available: // Create a cursor Cursor cursor = Base.contentResover().query(Phone.CONTENT_URI, null, null, null, null); if (cursor.moveToNext()) { Log.d("CALLOG", cursor.getString(cursor.getColumnIndexOrThrow(Phone.NUMBER))); } The problem is that i only get a few phone numbers returned, while i expect to get all... What am I doing wrong? Manish Khot I dont think there

Broadcast Intent on contact added/edited/changed - android

随声附和 提交于 2019-11-29 12:44:16
In my app, I have a service in which I want to listen for any changes in contacts i.e., when any contact is added or edited in the native contacts app or through any other app. Is there any broadcast intent which I can register to for this purpose? Or is there any other way to achieve this? atomman Found someone with a similar problem, his solution was using RawContacts. Broadcast on contact add/change? http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html 来源: https://stackoverflow.com/questions/14038956/broadcast-intent-on-contact-added-edited-changed

How to Update contact image using contact provider operation.

穿精又带淫゛_ 提交于 2019-11-29 11:54:34
The following code is used to update the image but it throws illegal or bad value exception.any body can solve this. Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap(); File f = new File(picturePath); Uri photoUri = Uri.fromFile(f); add to array list coding ops.add(ContentProviderOperation .newUpdate(ContactsContract.Data.CONTENT_URI) .withSelection( ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?", new String[] { contactid, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE }) .withValue(Photo.Photo_Uri,photoUri ).build()); Try the

Custom fields on new contact

大兔子大兔子 提交于 2019-11-29 11:21:16
This is the 'add new contact' window. Is it possible to create custom data fields in this window? My current custom fields are only visible on the 'contact details' window. It is possible to launch a new Add New Contact activity when the user clicks on the add new contact button. For that you will have to create your own activity and setContentView(R.layout.YOUR_CUSTOM_ACTIVITY_SCREEN) . Now the next step is important. Add the following lines to the ManifestFile of your application: <activity android:name=".YOUR_CUSTOM_ACTIVITY" > <intent-filter> <action android:name="android.intent.action

onActivityResult For Fragment

给你一囗甜甜゛ 提交于 2019-11-29 10:39:42
问题 I currently have a base activity which is hosting a single fragment. Inside the fragment I have a method which starts the contact chooser. private void chooseContacts() { Intent pickContactIntent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST); } When this activity returns how should I capture the results. I have tried adding

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

Android Get Contact Picture from Call Log

我的梦境 提交于 2019-11-29 08:10:36
It was pretty easy to get the Contact picture when querying the People.CONTENT_URI , with a simple People.loadContactPhoto(activity, ContentUris.withAppendedId(People.CONTENT_URI, contactId) because I knew the contact Id. Now I need to do the same thing after accesing the Call log. With: String[] strFields = { android.provider.CallLog.Calls.CACHED_NAME, android.provider.CallLog.Calls.NUMBER, }; String strUriCalls="content://call_log/calls"; Uri UriCalls = Uri.parse(strUriCalls); Cursor cursorLog = this.getContentResolver().query(UriCalls, strFields, null, null, null); I get the list from call

get Email Address from contact list

烈酒焚心 提交于 2019-11-29 08:05:21
I getting contact list by permission android:name="android.permission.READ_CONTACTS" Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intent, PICK_CONTACT); but how to get Email address from public void onActivityResult(int reqCode, int resultCode, Intent data) { //what should i have to write to fetch email address of selected contact // I wrote like below but i could not get result if (resultCode == Activity.RESULT_OK) { try{ Uri contactData = data.getData(); Cursor cursorEmail = getContentResolver().query(contactData,null,null,null