微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.provider.Contacts.ContactMethods的实例源码

项目:buildAPKsApps    文件RecipientsAdapter.java   
@Override
public final void bindView(View view,Context context,Cursor cursor) {
    TextView name = (TextView) view.findViewById(R.id.name);
    name.setText(cursor.getString(NAME_INDEX));

    TextView label = (TextView) view.findViewById(R.id.label);
    int type = cursor.getInt(TYPE_INDEX);
    if (cursor.getColumnCount() == EMAIL_COLUMN_COUNT) {
        int kind = cursor.getInt(KIND_INDEX);
        label.setText(ContactMethods.getdisplayLabel(
                mContext,kind,type,cursor.getString(LABEL_INDEX)));
    } else {
        label.setText(Phones.getdisplayLabel(mContext,cursor.getString(LABEL_INDEX)));
    }

    TextView number = (TextView) view.findViewById(R.id.number);
    number.setText("(" + cursor.getString(NUMBER_INDEX) + ")");
}
项目:alternate-java-bridge-library    文件EmailAddressAdapter.java   
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
  String where = null;

  if (constraint != null) {
    String filter = DatabaseUtils.sqlEscapestring(constraint.toString() + '%');

    StringBuilder s = new StringBuilder();
    s.append("(people.name LIKE ");
    s.append(filter);
    s.append(") OR (contact_methods.data LIKE ");
    s.append(filter);
    s.append(")");

    where = s.toString();
  }

  return contentResolver.query(ContactMethods.CONTENT_EMAIL_URI,PROJECTION,where,null,SORT_ORDER);
}
项目:flingtap-done    文件ContactLocationOverlayItemsPart.java   
public void onAddressGeocodeFound(GeoPoint geoPoint) {
    addOverlayItem(overlayItems,personId,geoPoint.getLatitudeE6(),geoPoint.getLongitudeE6(),mContactData);
    mContactData = null;

    if(mContactMethodPostalCursor.movetoNext()){
        mContactData = mContactMethodPostalCursor.getString(ContactMethodProjectionGps.CONTACT_M_DATA_INDEX);
        Uri postalContactMethodUri = ContentUris.withAppendedId(ContactMethods.CONTENT_URI,mContactMethodPostalCursor.getInt(ContactMethodProjectionGps.CONTACT_M_ID_INDEX));
        mGeocodeAddresspart.resolveAddressposition(mContactData,postalContactMethodUri,this);
    }else{
        mContactMethodPostalCursor.close();
        personId = -1l;
        if(itr.hasNext()){
            resolveForPerson(overlayItems);
        }else{
            mListener.onOverlayItemsResolved(overlayItems);
        }
    }       
}
项目:flingtap-done    文件LocationUtil.java   
/**
 * Checks whether the contact refered to by the URI contains any postal contact methods.
 *    Postal contact methods usually can be geocoded and thus can be used for proximity alerts.
 *    
 * @param uri A android.provider.Contacts.People.CONTENT_URI with id.
 * @return
 */
protected static boolean doesContactUriContainLocationInfoSDK3(Context ctx,Uri uri) throws RuntimeException {

    Long personId = ContentUris.parseId(uri);
    if( personId < 0 ){
        // Whoops,bad data! Bail.
        Exception exp = (Exception)(new Exception("URI missing id.").fillInStackTrace());
        Log.e(TAG,"ERR0003F URI missing id.");
        ErrorUtil.handleExceptionNotifyUserAndThrow("ERR0003F",exp,ctx);
    }

    // ******************************************************
    // Find the postal address that the user wants to use
    // ******************************************************

    // Get a list of the postal addresses
    Cursor mContactMethodPostalCursor = ctx.getContentResolver().query(ContactMethods.CONTENT_URI,ContactMethodProjectionGps.CONTACT_METHODS_PROJECTION,ContactMethods.PERSON_ID+"=? AND "+ContactMethodsColumns.KIND+"=?",new String[]{personId.toString(),String.valueOf(Contacts.KIND_POSTAL)},null); 
    int count = mContactMethodPostalCursor.getCount();
    mContactMethodPostalCursor.close();

    // Zero postal addresses
    if( count < 1){ 
        // No postal addresses exist,so no GPS locations can exist,right? 
        return false;           
    }
    return true;
}
项目:flingtap-done    文件ContactLocationOverlayItemsPart.java   
private void resolveForPerson(ArrayList<OverlayItem> overlayItems) {
    personId = ContentUris.parseId(itr.next());
    if( personId < 0 ){
        // Whoops,bad data! Bail.
        Exception exp = (Exception)(new Exception("Missing or incomplete Contacts.People.CONTENT_URI.").fillInStackTrace());
        Log.e(TAG,"ERR0001H",exp);
        ErrorUtil.handleExceptionNotifyUserAndThrow("ERR0001H",mContext);
    }

    // ******************************************************
    // Find the postal address that the user wants to use
    // ******************************************************

    // Get a list of the postal addresses
    mContactMethodPostalCursor = mContext.getContentResolver().query(ContactMethods.CONTENT_URI,// Todo: This won't work for Androic 2.x and above phones. 
            ContactMethods.PERSON_ID+"=? AND "+ContactMethodsColumns.KIND+"=?",null); 
    if(mContactMethodPostalCursor.movetoNext()){
        Uri postalContactMethodUri = ContentUris.withAppendedId(ContactMethods.CONTENT_URI,mContactMethodPostalCursor.getInt(ContactMethodProjectionGps.CONTACT_M_ID_INDEX));
        mContactData = mContactMethodPostalCursor.getString(ContactMethodProjectionGps.CONTACT_M_DATA_INDEX);
        mGeocodeAddresspart.resolveAddressposition(mContactData,this);
    }else{
        mContactMethodPostalCursor.close();
        personId = -1l;
        if(itr.hasNext()){
            resolveForPerson(overlayItems);
        }else{
            mListener.onOverlayItemsResolved(overlayItems);
        }           
    }
}
项目:flingtap-done    文件SelectPostalContactMethodActivity.java   
protected Uri constructreturnData(Long personId,Long contactMethodId){
    Builder builder = ContentUris.appendId(Contacts.People.CONTENT_URI.buildUpon(),personId);
    builder.appendpath(Contacts.People.ContactMethods.CONTENT_DIRECTORY);
    builder.appendpath(contactMethodId.toString());
    Uri returnData = builder.build();
    return returnData;
}
项目:appinventor-extensions    文件EmailAddressAdapter.java   
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {

  String where = null;
  android.net.Uri db = null;
  StringBuilder s = new StringBuilder();

  if (constraint != null) {
    String filter = DatabaseUtils.sqlEscapestring(constraint.toString() + '%');

    if (SdkLevel.getLevel() >= SdkLevel.LEVEL_HONEYCOMB_MR1) {
      db = HoneycombMR1Util.getDataContentUri();
      s.append("(" + HoneycombMR1Util.getDataMimeType() + "='" + HoneycombMR1Util.getEmailType() + "')");
      s.append(" AND ");
      s.append("(display_name LIKE ");
      s.append(filter);
      s.append(")");
    } else {
      db = ContactMethods.CONTENT_EMAIL_URI;
      s.append("(name LIKE ");
      s.append(filter);
      s.append(") OR (display_name LIKE ");
      s.append(filter);
      s.append(")");
    }
  }
  where = s.toString();

  // Note(hal): This lists the column names in the table being accessed,since they aren't
  // obvIoUs to me from the documentation
  if (DEBUG) {
    Cursor c = context.getContentResolver().query(db,null);
    Log.d(TAG,"listing columns");
    for (int i = 0; i<c.getColumnCount(); i++) {
      Log.d(TAG,"column " + i + "=" + c.getColumnName(i));
    }
  }

  if (SdkLevel.getLevel() >= SdkLevel.LEVEL_HONEYCOMB_MR1) {
    return contentResolver.query(db,POST_HONEYCOMB_PROJECTION,SORT_ORDER);
  } else {
    return contentResolver.query(db,PRE_HONEYCOMB_PROJECTION,SORT_ORDER);
  }
}
项目:flingtap-done    文件SelectPostalContactMethodActivity.java   
public static CharSequence determineContactMethodLabel(Context context,int kind,int type,String otherLabel) {
    CharSequence returnLabel = ContactMethods.getdisplayLabel(context,otherLabel); 
    return returnLabel;
}
项目:fnzy    文件CursorToMessage.java   
@TargetApi(Build.VERSION_CODES.ECLAIR)
private String getPrimaryEmail(final long personId,final String number) {
    if (personId <= 0) {
      return getUnkNownEmail(number);
    }
    String primaryEmail = null;

    // Get all e-mail addresses for that person.
    Cursor c;
    int columnIndex;
    if (NEW_CONTACT_API) {
      c = mContext.getContentResolver().query(
          ECLAIR_CONTENT_URI,new String[] { ContactsContract.CommonDataKinds.Email.DATA },ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?",new String[] { String.valueOf(personId) },ContactsContract.CommonDataKinds.Email.IS_PRIMARY + " DESC");
      columnIndex = c != null ? c.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA) : -1;
    } else {
      c = mContext.getContentResolver().query(
          ContactMethods.CONTENT_EMAIL_URI,new String[] { ContactMethods.DATA },ContactMethods.PERSON_ID + " = ?",ContactMethods.ISPRIMARY + " DESC");
      columnIndex = c!= null ? c.getColumnIndex(ContactMethods.DATA) : -1;
    }

    // Loop over cursor and find a Gmail address for that person.
    // If there is none,pick first e-mail address.
    while (c != null && c.movetoNext()) {
        String e = c.getString(columnIndex);
        if (primaryEmail == null) {
            primaryEmail = e;
        }
        if (isGmailAddress(e)) {
            primaryEmail = e;
            break;
        }
    }

    if (c != null) c.close();
    return (primaryEmail != null) ? primaryEmail : getUnkNownEmail(number);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。