![](/img/trans.png)
[英]How to access the contact details within the WhatsApp app in android mobile development?
[英]How to add contact in Android like skype, whatsapp in native contact app?
我正在创建联系人应用程序,但想从我的应用程序(如Skype或WhatsApp)中在本地android联系人应用程序中添加联系人。 我需要扩展什么类来实现此功能?
这正是我要创建的图片:
好吧,如果我了解您的需求。 您要使用本机Android联系人列表。如果是这样,请按照以下步骤操作:
一个简短的例子。 开火意图
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
//Receive the result
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
switch (requestCode) {
case CONTACT_PICKER_RESULT:
//deal with the resulting contact info. I built a separate util class for that.. but here is an example of the code.
String[] projection = { ContactsContract.CommonDataKinds.Phone._ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Email.ADDRESS };
Uri result = data.getData();
String id = result.getLastPathSegment();
ContentResolver contentResolver = getActivity().getContentResolver();
//return cursor
cur = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection,
ContactsContract.CommonDataKinds.Phone._ID + " like \"" + idUser + "%\"", null, null);
//Use the cursor to return what you need.
}
}
这是对游标的示例调用。 请在android文档中阅读有关联系人游标的更多信息。
email = emailCursor.getString(emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.