【问题标题】:Get my personal data contact获取我的个人数据联系人
【发布时间】:2016-02-02 11:07:48
【问题描述】:

我需要获取我的个人联系方式。在 android 4.0 及更高版本中,我们有一个我的数据联系人。我试过ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,但我的所有联系人都没有我的数据联系人。知道如何获得吗?

这是我的代码:

public String getMyName(ContentResolver resolver){

    Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
    String[] columns = new String[] {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
            ContactsContract.CommonDataKinds.Phone.NUMBER};
    Cursor people = resolver.query(uri, columns, null, null, null);
    try {
        int nameIndex = people.getColumnIndex(columns[0]);
        int numberIndex = people.getColumnIndex(columns[1]);

        people.moveToFirst();
        do{
            Log.d("Contact result", "Contact name: " + people.getString(nameIndex) + " contact phone: " + people.getString(numberIndex));
        } while (people.moveToNext());
    }catch (NullPointerException e){
        Log.d("Exception", "Null pointer on get personal data");
    }
    return null;
}

【问题讨论】:

    标签: android android-contacts


    【解决方案1】:

    好的。我找到了它的图书馆。

    https://gist.github.com/remelpugh/4072663

    这有助于获取我的个人数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-16
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多