Android和Facebook的联系人选择器发卡行 [英] Android and Facebook Contact Picker Issuer
问题描述
短版我的问题是:如何访问联系人的电话号码从第三方应用程序进行同步的
The short version of my question is: How do I access the phone numbers of contacts that were synced from 3rd party apps?
下面是长的版本:
我可以很容易地访问常规Android的接触pretty的。问题是,当联系人列表中的唯一信息是同步与像Facebook或LinkedIn第三方应用程序。如果我身体去和输入某人的电话号码输入到谷歌联系人列表,一切工作正常。
I can access the regular Android contacts pretty easily. The issue is when the only information in the contact list is synced with a 3rd party app like Facebook or LinkedIn. If I physically went and typed someone's phone number into the Google Contacts List, everything works fine.
但是,如果这个电话号码的同步我的Facebook账户,以我的联系人列表来了,没有电话号码显示出来,即使当我浏览到谷歌的pre-取得了联系列表,我可以看到一个电话号码居然附到接触。这里是code我用得到的电话号码。
However, if this phone number came from syncing my facebook account to my contact list, no phone number shows up, even though if I navigated to Google's pre-made contact list I can see a phone number is actually attached to the contact. Here is the code I use for getting the phone numbers.
public void populateNumberLists(View view)
{
LinearLayout ll = (LinearLayout) view;
TextView tv = (TextView) ll.findViewById(R.id.contactEntryText);
String str = (String) tv.getText();
Cursor cursor = getNumbers(str);
String[] fields = new String[] {
cursor.getColumnName(1).toString()
};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.numberentry, cursor,
fields, new int[] {R.id.numberEntryText});
mNumberList.setAdapter(adapter);
}
private Cursor getNumbers(String str)
{
final Uri URIs = ContactsContract.Contacts.CONTENT_URI;
final String ID = ContactsContract.Contacts.LOOKUP_KEY;
String id = "";
ContentResolver cr = getContentResolver();
Cursor cu = cr.query(URIs, null, ContactsContract.Contacts.DISPLAY_NAME + " = '" + str + "'", null, null);
if (cu.moveToFirst()) {
id = cu.getString(cu.getColumnIndex(ID));
}
cu.close();
// Run query
Uri uri = Phone.CONTENT_URI;
String[] projection = new String[] {
Phone._ID,
Phone.NUMBER
};
String selection = Phone.LOOKUP_KEY + " = '" + id + "' and (" + Phone.TYPE + " = '" + Phone.TYPE_HOME+"' or " + Phone.TYPE + " = '" + Phone.TYPE_MOBILE+"' or " + Phone.TYPE + " = '" + Phone.TYPE_WORK+"' or " + Phone.TYPE + " = '" + Phone.TYPE_WORK_MOBILE+"')";
String[] selectionArgs = null;
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
return managedQuery(uri, projection, selection, selectionArgs, null);
}
基本上,populateNumberLists功能需要点击的项目从列表视图,决定了从列表中联系人被点击并调用函数getNumbers。
Basically, the populateNumberLists function takes a clicked item from a list view, determines which contact from the list was clicked and calls the function getNumbers.
在getNumbers函数需要单击的实际名称,获取查找键的名称,然后获取所有与该查找键相关联的电话号码。
The getNumbers function takes actual name that was clicked, gets the lookup key for that name, then grabs all the phone numbers associated with that lookup key.
呵呵,与此相关的,在联系人列表中显示的唯一名字的人在那里ContactsContract.Contacts.HAS_PHONE_NUMBER等于1。所以,我知道,所有可以选择的联系人有一个电话号码连接。
Oh, related to this, the only names displayed in the contact list are ones where ContactsContract.Contacts.HAS_PHONE_NUMBER equals 1. So I know that all the contacts that can be selected have a phone number attached.
推荐答案
Facebook正在不包括在ContactPicker因为Facebook禁止的。 这是一个政治上的事情,并不会很快得到解决:谷歌希望Facebook的共享数据,Facebook的使用谷歌,但不同意。
Facebook is not included in the ContactPicker because Facebook forbid that. This is a politically thing and won't be solved soon: Google wants Facebook to share data, Facebook uses Google but doesn't share..
这篇关于Android和Facebook的联系人选择器发卡行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!