java类android.provider.ContactsContract.PhoneLookup的实例源码

ContactAccessor.java 文件源码 项目:PeSanKita-android 阅读 28 收藏 0 点赞 0 评论 0
public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = TextSecureDirectory.getInstance(context).getActiveNumbers();
  final Collection<ContactData> lookupData = new ArrayList<>(pushNumbers.size());

  for (String pushNumber : pushNumbers) {
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber));
    Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null);
    try {
      if (lookupCursor != null && lookupCursor.moveToFirst()) {
        final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1));
        contactData.numbers.add(new NumberData("XecureChat", pushNumber));
        lookupData.add(contactData);
      }
    } finally {
      if (lookupCursor != null)
        lookupCursor.close();
    }
  }
  return lookupData;
}
ContactAccessor.java 文件源码 项目:PeSanKita-android 阅读 24 收藏 0 点赞 0 评论 0
public boolean isSystemContact(Context context, String number) {
  Uri      uri        = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  String[] projection = new String[]{PhoneLookup.DISPLAY_NAME, PhoneLookup.LOOKUP_KEY,
                                     PhoneLookup._ID, PhoneLookup.NUMBER};
  Cursor   cursor     = context.getContentResolver().query(uri, projection, null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      return true;
    }
  } finally {
    if (cursor != null) cursor.close();
  }

  return false;
}
ContactIdentityManagerGingerbread.java 文件源码 项目:PeSanKita-android 阅读 23 收藏 0 点赞 0 评论 0
private Uri getContactUriForNumber(String number) {
  String[] PROJECTION = new String[] {
    PhoneLookup.DISPLAY_NAME,
    PhoneLookup.LOOKUP_KEY,
    PhoneLookup._ID,
  };

  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(uri, PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
ContactIdentityManagerICS.java 文件源码 项目:PeSanKita-android 阅读 28 收藏 0 点赞 0 评论 0
@SuppressLint("NewApi")
@Override
public Uri getSelfIdentityUri() {
  String[] PROJECTION = new String[] {
      PhoneLookup.DISPLAY_NAME,
      PhoneLookup.LOOKUP_KEY,
      PhoneLookup._ID,
  };

  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI,
                                                  PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
ContactBadge.java 文件源码 项目:SOS-The-Healthcare-Companion 阅读 32 收藏 0 点赞 0 评论 0
@Override
public void onClick(View v) {
    // If contact has been assigned, mExtras should no longer be null, but do a null check
    // anyway just in case assignContactFromPhone or Email was called with a null bundle or
    // wasn't assigned previously.
    final Bundle extras = (mExtras == null) ? new Bundle() : mExtras;
    if (mContactUri != null) {
        QuickContact.showQuickContact(getContext(), ContactBadge.this, mContactUri, QuickContact.MODE_LARGE, mExcludeMimes);
    } else if (mContactEmail != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactEmail);
        mQueryHandler.startQuery(Constants.TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
                EMAIL_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else if (mContactPhone != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactPhone);
        mQueryHandler.startQuery(Constants.TOKEN_PHONE_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, mContactPhone),
                PHONE_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else {
        // If a contact hasn't been assigned, don't react to click.
        return;
    }
}
ContactAccessor.java 文件源码 项目:Cable-Android 阅读 23 收藏 0 点赞 0 评论 0
public boolean isSystemContact(Context context, String number) {
  Uri      uri        = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  String[] projection = new String[]{PhoneLookup.DISPLAY_NAME, PhoneLookup.LOOKUP_KEY,
                                     PhoneLookup._ID, PhoneLookup.NUMBER};
  Cursor   cursor     = context.getContentResolver().query(uri, projection, null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      return true;
    }
  } finally {
    if (cursor != null) cursor.close();
  }

  return false;
}
ContactAccessor.java 文件源码 项目:Cable-Android 阅读 26 收藏 0 点赞 0 评论 0
public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = TextSecureDirectory.getInstance(context).getActiveNumbers();
  final Collection<ContactData> lookupData = new ArrayList<>(pushNumbers.size());

  for (String pushNumber : pushNumbers) {
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber));
    Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null);
    try {
      if (lookupCursor != null && lookupCursor.moveToFirst()) {
        final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1));
        contactData.numbers.add(new NumberData("TextSecure", pushNumber));
        lookupData.add(contactData);
      }
    } finally {
      if (lookupCursor != null)
        lookupCursor.close();
    }
  }
  return lookupData;
}
ContactIdentityManagerGingerbread.java 文件源码 项目:Cable-Android 阅读 24 收藏 0 点赞 0 评论 0
private Uri getContactUriForNumber(String number) {
  String[] PROJECTION = new String[] {
    PhoneLookup.DISPLAY_NAME,
    PhoneLookup.LOOKUP_KEY,
    PhoneLookup._ID,
  };

  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(uri, PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
ContactIdentityManagerICS.java 文件源码 项目:Cable-Android 阅读 26 收藏 0 点赞 0 评论 0
@SuppressLint("NewApi")
@Override
public Uri getSelfIdentityUri() {
  String[] PROJECTION = new String[] {
      PhoneLookup.DISPLAY_NAME,
      PhoneLookup.LOOKUP_KEY,
      PhoneLookup._ID,
  };

  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI,
                                                  PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
ContactBadge.java 文件源码 项目:templated-messaging 阅读 28 收藏 0 点赞 0 评论 0
@Override
public void onClick(View v) {
    // If contact has been assigned, mExtras should no longer be null, but do a null check
    // anyway just in case assignContactFromPhone or Email was called with a null bundle or
    // wasn't assigned previously.
    final Bundle extras = (mExtras == null) ? new Bundle() : mExtras;
    if (mContactUri != null) {
        QuickContact.showQuickContact(getContext(), ContactBadge.this, mContactUri, QuickContact.MODE_LARGE, mExcludeMimes);
    } else if (mContactEmail != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactEmail);
        mQueryHandler.startQuery(Constants.TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
                EMAIL_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else if (mContactPhone != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactPhone);
        mQueryHandler.startQuery(Constants.TOKEN_PHONE_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, mContactPhone),
                PHONE_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else {
        // If a contact hasn't been assigned, don't react to click.
        return;
    }
}
ContactAccessor.java 文件源码 项目:TextSecure 阅读 27 收藏 0 点赞 0 评论 0
public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = TextSecureDirectory.getInstance(context).getActiveNumbers();
  final Collection<ContactData> lookupData = new ArrayList<ContactData>(pushNumbers.size());

  for (String pushNumber : pushNumbers) {
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber));
    Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null);
    try {
      if (lookupCursor != null && lookupCursor.moveToFirst()) {
        final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1));
        contactData.numbers.add(new NumberData("TextSecure", pushNumber));
        lookupData.add(contactData);
      }
    } finally {
      if (lookupCursor != null)
        lookupCursor.close();
    }
  }
  return lookupData;
}
ContactIdentityManagerGingerbread.java 文件源码 项目:TextSecure 阅读 28 收藏 0 点赞 0 评论 0
private Uri getContactUriForNumber(String number) {
  String[] PROJECTION = new String[] {
    PhoneLookup.DISPLAY_NAME,
    PhoneLookup.LOOKUP_KEY,
    PhoneLookup._ID,
  };

  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(uri, PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
ContactIdentityManagerICS.java 文件源码 项目:TextSecure 阅读 22 收藏 0 点赞 0 评论 0
@SuppressLint("NewApi")
@Override
public Uri getSelfIdentityUri() {
  String[] PROJECTION = new String[] {
      PhoneLookup.DISPLAY_NAME,
      PhoneLookup.LOOKUP_KEY,
      PhoneLookup._ID,
  };

  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI,
                                                  PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
RecipientProvider.java 文件源码 项目:TextSecure 阅读 34 收藏 0 点赞 0 评论 0
private RecipientDetails getRecipientDetails(Context context, String number) {
  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = context.getContentResolver().query(uri, CALLER_ID_PROJECTION,
                                                     null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      Uri contactUri      = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
      Bitmap contactPhoto = ContactPhotoFactory.getContactPhoto(context, Uri.withAppendedPath(Contacts.CONTENT_URI,
                                                                                              cursor.getLong(2)+""));
      return new RecipientDetails(cursor.getString(0), cursor.getString(3), contactUri, contactPhoto,
                                  BitmapUtil.getCircleCroppedBitmap(contactPhoto));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
ContactBadge.java 文件源码 项目:Android-ContactPicker 阅读 41 收藏 0 点赞 0 评论 0
@Override
public void onClick(View v) {
    // If contact has been assigned, mExtras should no longer be null, but do a null check
    // anyway just in case assignContactFromPhone or Email was called with a null bundle or
    // wasn't assigned previously.
    final Bundle extras = (mExtras == null) ? new Bundle() : mExtras;
    if (mContactUri != null) {
        QuickContact.showQuickContact(getContext(), ContactBadge.this, mContactUri, QuickContact.MODE_LARGE, mExcludeMimes);
    } else if (mContactEmail != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactEmail);
        mQueryHandler.startQuery(Constants.TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
                EMAIL_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else if (mContactPhone != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactPhone);
        mQueryHandler.startQuery(Constants.TOKEN_PHONE_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, mContactPhone),
                PHONE_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else {
        // If a contact hasn't been assigned, don't react to click.
        return;
    }
}
ContactAccessor.java 文件源码 项目:TextSecureSMP 阅读 23 收藏 0 点赞 0 评论 0
public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = TextSecureDirectory.getInstance(context).getActiveNumbers();
  final Collection<ContactData> lookupData = new ArrayList<ContactData>(pushNumbers.size());

  for (String pushNumber : pushNumbers) {
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber));
    Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null);
    try {
      if (lookupCursor != null && lookupCursor.moveToFirst()) {
        final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1));
        contactData.numbers.add(new NumberData("TextSecure", pushNumber));
        lookupData.add(contactData);
      }
    } finally {
      if (lookupCursor != null)
        lookupCursor.close();
    }
  }
  return lookupData;
}
ContactIdentityManagerGingerbread.java 文件源码 项目:TextSecureSMP 阅读 22 收藏 0 点赞 0 评论 0
private Uri getContactUriForNumber(String number) {
  String[] PROJECTION = new String[] {
    PhoneLookup.DISPLAY_NAME,
    PhoneLookup.LOOKUP_KEY,
    PhoneLookup._ID,
  };

  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(uri, PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
ContactIdentityManagerICS.java 文件源码 项目:TextSecureSMP 阅读 24 收藏 0 点赞 0 评论 0
@SuppressLint("NewApi")
@Override
public Uri getSelfIdentityUri() {
  String[] PROJECTION = new String[] {
      PhoneLookup.DISPLAY_NAME,
      PhoneLookup.LOOKUP_KEY,
      PhoneLookup._ID,
  };

  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI,
                                                  PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
RecipientProvider.java 文件源码 项目:TextSecureSMP 阅读 24 收藏 0 点赞 0 评论 0
private RecipientDetails getRecipientDetails(Context context, String number) {
  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = context.getContentResolver().query(uri, CALLER_ID_PROJECTION,
                                                     null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      Uri      contactUri   = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
      String   name         = cursor.getString(3).equals(cursor.getString(0)) ? null : cursor.getString(0);
      Drawable contactPhoto = ContactPhotoFactory.getContactPhoto(context,
                                                                  Uri.withAppendedPath(Contacts.CONTENT_URI, cursor.getLong(2) + ""),
                                                                  name);
      return new RecipientDetails(cursor.getString(0), cursor.getString(3), contactUri, contactPhoto);
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return new RecipientDetails(null, number, null, ContactPhotoFactory.getDefaultContactPhoto(context, null));
}
ContactsRetriever.java 文件源码 项目:Wi-SMS 阅读 23 收藏 0 点赞 0 评论 0
public static String getContactId(String phoneNumber, Context context) {
    ContentResolver mResolver = context.getContentResolver();

    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
            Uri.encode(phoneNumber));

    Cursor cursor = mResolver.query(uri, new String[] {
            PhoneLookup.DISPLAY_NAME, PhoneLookup._ID }, null, null, null);

    String contactId = "";

    if (cursor.moveToFirst()) {
        do {
            contactId = cursor.getString(cursor
                    .getColumnIndex(PhoneLookup._ID));
        } while (cursor.moveToNext());
    }

    cursor.close();
    cursor = null;
    return contactId;
}
ContactsRetriever.java 文件源码 项目:Wi-SMS 阅读 20 收藏 0 点赞 0 评论 0
public static String getContactName(String phoneNumber, Context context) {
    ContentResolver mResolver = context.getContentResolver();

    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
            Uri.encode(phoneNumber));

    Cursor cursor = mResolver.query(uri, new String[] {
            PhoneLookup.DISPLAY_NAME, PhoneLookup._ID }, null, null, null);

    String contactId = "";

    if (cursor.moveToFirst()) {
        do {
            contactId = cursor.getString(cursor
                    .getColumnIndex(PhoneLookup.DISPLAY_NAME));
        } while (cursor.moveToNext());
    }

    cursor.close();
    cursor = null;
    return contactId;
}
SmsReceiver.java 文件源码 项目:Raven-Messenger 阅读 31 收藏 0 点赞 0 评论 0
public static String getContactName(Context context, String phoneNumber) {
    ContentResolver cr = context.getContentResolver();
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
    Cursor cursor = cr.query(uri, new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null);
    if (cursor == null) {
        return null;
    }
    String contactName = null;
    if (cursor.moveToFirst()) {
        contactName = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
    }

    if (cursor != null && !cursor.isClosed()) {
        cursor.close();
    }

    return contactName;
}
MainActivity.java 文件源码 项目:Raven-Messenger 阅读 23 收藏 0 点赞 0 评论 0
public static String getContactName(Context context, String phoneNumber) {
    if (phoneNumber == null || phoneNumber.length() == 0)
        return phoneNumber;
    ContentResolver cr = context.getContentResolver();
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
    Cursor cursor = cr.query(uri, new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null);
    if (cursor == null) {
        return null;
    }
    String contactName = null;
    if (cursor.moveToFirst()) {
        contactName = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
    }

    if (cursor != null && !cursor.isClosed()) {
        cursor.close();
    }

    return contactName;
}
OpenFitService.java 文件源码 项目:OpenFit 阅读 31 收藏 0 点赞 0 评论 0
public String getContactName(String phoneNumber) {
    ContentResolver cr = this.getContentResolver();
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
    Cursor cursor = cr.query(uri, new String[] {PhoneLookup.DISPLAY_NAME}, null, null, null);
    if(cursor == null) {
        return null;
    }
    String contactName = null;
    if(cursor.moveToFirst()) {
        contactName = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
    }
    if(cursor != null && !cursor.isClosed()) {
        cursor.close();
    }
    return contactName;
}
Helper.java 文件源码 项目:launcherforblind 阅读 40 收藏 0 点赞 0 评论 0
public static String getContactName(Context ctx, String phoneNumber) {
    final ContentResolver cr = ctx.getContentResolver();
    final Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
            Uri.encode(phoneNumber));
    Cursor cursor = null;
    String contactName = phoneNumber;
    try {
        cursor = cr.query(uri, new String[] { PhoneLookup.DISPLAY_NAME },
                null, null, null);
        if (cursor == null) {
            return null;
        }

        if (cursor.moveToFirst()) {
            contactName = cursor.getString(cursor
                    .getColumnIndex(PhoneLookup.DISPLAY_NAME));
        }
    } finally {
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
    }
    return contactName;
}
ContactIdentityManagerGingerbread.java 文件源码 项目:Securecom-Messaging 阅读 26 收藏 0 点赞 0 评论 0
private Uri getContactUriForNumber(String number) {
  String[] PROJECTION = new String[] {
    PhoneLookup.DISPLAY_NAME,
    PhoneLookup.LOOKUP_KEY,
    PhoneLookup._ID,
  };

  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(uri, PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
ContactIdentityManagerICS.java 文件源码 项目:Securecom-Messaging 阅读 23 收藏 0 点赞 0 评论 0
@SuppressLint("NewApi")
@Override
public Uri getSelfIdentityUri() {
  String[] PROJECTION = new String[] {
      PhoneLookup.DISPLAY_NAME,
      PhoneLookup.LOOKUP_KEY,
      PhoneLookup._ID,
  };

  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI,
                                                  PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
RecipientProvider.java 文件源码 项目:Securecom-Messaging 阅读 23 收藏 0 点赞 0 评论 0
private RecipientDetails getRecipientDetails(Context context, String number) {
  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = context.getContentResolver().query(uri, CALLER_ID_PROJECTION,
                                                     null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      Uri contactUri      = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
      Bitmap contactPhoto = ContactPhotoFactory.getContactPhoto(context, Uri.withAppendedPath(Contacts.CONTENT_URI,
                                                                                              cursor.getLong(2)+""));
      return new RecipientDetails(cursor.getString(0), cursor.getString(3), contactUri, contactPhoto,
                                  BitmapUtil.getCircleCroppedBitmap(contactPhoto));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
ContactAccessor.java 文件源码 项目:Securecom-Text 阅读 31 收藏 0 点赞 0 评论 0
public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = Directory.getInstance(context).getActiveNumbers();
  final Collection<ContactData> lookupData = new ArrayList<ContactData>(pushNumbers.size());

  for (String pushNumber : pushNumbers) {
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber));
    Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null);
    try {
      if (lookupCursor != null && lookupCursor.moveToFirst()) {
        final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1));
        contactData.numbers.add(new NumberData("TextSecure", pushNumber));
        lookupData.add(contactData);
      }
    } finally {
      if (lookupCursor != null)
        lookupCursor.close();
    }
  }
  return lookupData;
}
ContactIdentityManagerGingerbread.java 文件源码 项目:Securecom-Text 阅读 30 收藏 0 点赞 0 评论 0
private Uri getContactUriForNumber(String number) {
  String[] PROJECTION = new String[] {
    PhoneLookup.DISPLAY_NAME,
    PhoneLookup.LOOKUP_KEY,
    PhoneLookup._ID,
  };

  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(uri, PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}


问题


面经


文章

微信
公众号

扫码关注公众号