android-contacts

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

无人久伴 提交于 2019-11-30 10:14:30
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 = managedQuery(uri, projection, where, selectionArgs, sortOrder); if (result.moveToFirst()) { String phone = result

onActivityResult For Fragment

 ̄綄美尐妖づ 提交于 2019-11-30 07:53:18
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 a @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super

Android: Contact Picker Intent | Cannot instantiate the type Uri

纵饮孤独 提交于 2019-11-30 07:30:29
问题 I am trying to pick contacts with phone number only.And I am following this code static final int PICK_CONTACT_REQUEST = 1; // The request code ... private void pickContact() { Intent pickContactIntent = new Intent(Intent.ACTION_PICK, new Uri("content://contacts")); pickContactIntent.setType(Phone.CONTENT_TYPE); // Show user only contacts w/ phone numbers startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST); } But unfortunately, its showing an error: Cannot instantiate the type Uri

How to get all contacts first name, last name, email, phone number, etc without duplicates

元气小坏坏 提交于 2019-11-30 06:38:51
问题 I am trying to get details of all the contacts available in phone contacts using below code. But facing small issue of duplicate values. EDITED ACTUAL CODE STARTS :- private String refreshData() { String emaildata = ""; try { ContentResolver cr = getBaseContext().getContentResolver(); String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" + ("1") + "'"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; Cursor cur = cr .query(ContactsContract

Select multiple contacts from phone book in android

孤街浪徒 提交于 2019-11-30 01:54:15
I need to select contact numbers/emails from phone book in android. I have seen selecting one contact and getting the result back in onActivityResult from this link . But I need multiple contacts to be selected from the phone book. How to achieve this? I don't want to make my custom list, is there a way to use androids built in functionality? I am sharing code for select multiple contact from Phone Book. you have change little bit and you can achieve your goal. thanks getAllContacts(this.getContentResolver()); ListView lv = (ListView) findViewById(R.id.lv); ma = new MyAdapter(); lv.setAdapter

How to select multiple contacts from the phone using checkboxes

十年热恋 提交于 2019-11-29 21:58:06
问题 I am trying to select contacts available from the phone programmatically and I am using the below code Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE); startActivityForResult(intent, 1); However the question is How can I select multiple contacts at a time by using a checkbox in the contacts page? 回答1: You will have to read the Contacts programmatically and display them in a ListView in your Activity . Use CheckBox

How to show&handle contact details intents of apps?

六月ゝ 毕业季﹏ 提交于 2019-11-29 21:09:25
问题 Background Not sure how it's called, but when you open the contact-details screen of the contacts app, you see various apps there that you can click to perform actions on (such as calling and sending messages via Viber and WhatsApp) as such: The problem I don't know how those actions are called, so I can't find out how to investigate them. I tried searching for each social network, how to use it, but this seems like a lot of effort that might not even work well in the future. I wish to query

How to send and receive SMS from android app? [closed]

自闭症网瘾萝莉.ら 提交于 2019-11-29 19:44:27
I want to add sms sending feature in my app and also want option in which user can select the contacts from the contact list directly from the application. Is there way that contact list can be integrated with my application. Thanks And here is a Tutorial Showing step by step how to send SMS from an Android App. http://mobiforge.com/developing/story/sms-messaging-android Hope Androider's and my answer complets your answer! UPDATE: Since the link above has now gone dead: Disclaimer: I have not written the original article. I am just copying it here. The orignal author according to the article

Access email-id along with name and phone number from contact list in Android

人盡茶涼 提交于 2019-11-29 18:03:29
Here I am accessing name and phone number from mobile and uploading to server. I am not facing any problem in this. I have made some modifications to access email also. But I am not able to fetch the email. In place of email it is displaying phone number. I have used System.out.print to check the details. Here is my code. DisplayContact public class DisplayContact extends Activity implements OnItemClickListener{ //ArrayList to store name and phone number List<String> name1 = new ArrayList<String>(); List<String> phno1 = new ArrayList<String>(); List<String> email1 = new ArrayList<String>();

Add a custom field to a phone number

a 夏天 提交于 2019-11-29 15:56:18
问题 Am building an app that requires a custom contact field ('whitelist', if you were wondering) for every phone number. However, I only found a way of saving custom data for each contact, with Data.RAW_CONTACT_ID , but not for each phone number . I tried using Phone._id , but I got a java.nullpointerexception error. This is the code I have now: try{ //phoneId = get Phone._ID from cursor ContentValues values = new ContentValues(); values.put(Data.DATA1, "yes"); int state = getContentResolver()