当前位置: 首页>>代码示例>>Java>>正文


Java ContactMethods类代码示例

本文整理汇总了Java中android.provider.Contacts.ContactMethods的典型用法代码示例。如果您正苦于以下问题:Java ContactMethods类的具体用法?Java ContactMethods怎么用?Java ContactMethods使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContactMethods类属于android.provider.Contacts包,在下文中一共展示了ContactMethods类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bindView

import android.provider.Contacts.ContactMethods; //导入依赖的package包/类
@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, type, cursor.getString(LABEL_INDEX)));
    }

    TextView number = (TextView) view.findViewById(R.id.number);
    number.setText("(" + cursor.getString(NUMBER_INDEX) + ")");
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:19,代码来源:RecipientsAdapter.java

示例2: runQueryOnBackgroundThread

import android.provider.Contacts.ContactMethods; //导入依赖的package包/类
@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);
}
 
开发者ID:roadlabs,项目名称:alternate-java-bridge-library,代码行数:21,代码来源:EmailAddressAdapter.java

示例3: onAddressGeocodeFound

import android.provider.Contacts.ContactMethods; //导入依赖的package包/类
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);
		}
	}		
}
 
开发者ID:SpencerRiddering,项目名称:flingtap-done,代码行数:19,代码来源:ContactLocationOverlayItemsPart.java

示例4: doesContactUriContainLocationInfoSDK3

import android.provider.Contacts.ContactMethods; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SpencerRiddering,项目名称:flingtap-done,代码行数:38,代码来源:LocationUtil.java

示例5: resolveForPerson

import android.provider.Contacts.ContactMethods; //导入依赖的package包/类
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", exp, 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,
			ContactMethodProjectionGps.CONTACT_METHODS_PROJECTION, // TODO: This won't work for Androic 2.x and above phones. 
			ContactMethods.PERSON_ID+"=? AND "+ContactMethodsColumns.KIND+"=?", 
			new String[]{personId.toString(), String.valueOf(Contacts.KIND_POSTAL)}, 
			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, postalContactMethodUri, this);
	}else{
		mContactMethodPostalCursor.close();
		personId = -1l;
		if(itr.hasNext()){
			resolveForPerson(overlayItems);
		}else{
			mListener.onOverlayItemsResolved(overlayItems);
		}			
	}
}
 
开发者ID:SpencerRiddering,项目名称:flingtap-done,代码行数:34,代码来源:ContactLocationOverlayItemsPart.java

示例6: constructReturnData

import android.provider.Contacts.ContactMethods; //导入依赖的package包/类
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;
}
 
开发者ID:SpencerRiddering,项目名称:flingtap-done,代码行数:8,代码来源:SelectPostalContactMethodActivity.java

示例7: runQueryOnBackgroundThread

import android.provider.Contacts.ContactMethods; //导入依赖的package包/类
@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, null, null, null, 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,
        where, null, SORT_ORDER);
  } else {
    return contentResolver.query(db, PRE_HONEYCOMB_PROJECTION,
        where, null, SORT_ORDER);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:47,代码来源:EmailAddressAdapter.java

示例8: determineContactMethodLabel

import android.provider.Contacts.ContactMethods; //导入依赖的package包/类
public static CharSequence determineContactMethodLabel(Context context, int kind, int type, String otherLabel) {
	CharSequence returnLabel = ContactMethods.getDisplayLabel(context, kind, type, otherLabel); 
	return returnLabel;
}
 
开发者ID:SpencerRiddering,项目名称:flingtap-done,代码行数:5,代码来源:SelectPostalContactMethodActivity.java

示例9: getPrimaryEmail

import android.provider.Contacts.ContactMethods; //导入依赖的package包/类
@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 + " = ?", new String[] { String.valueOf(personId) },
          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);
}
 
开发者ID:zhenlonghe,项目名称:fnzy,代码行数:43,代码来源:CursorToMessage.java


注:本文中的android.provider.Contacts.ContactMethods类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。