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


Java Phones类代码示例

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


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

示例1: getPhoneNumbers

import android.provider.Contacts.Phones; //导入依赖的package包/类
public List<Phone> getPhoneNumbers(Context ctxt, long contactId, int flags) {
    ArrayList<Phone> phones = new ArrayList<Phone>();
    if ((flags & ContactsWrapper.URI_NBR) > 0) {
        Cursor pCur = ctxt.getContentResolver().query(
                Phones.CONTENT_URI,
                null,
                Phones.PERSON_ID + " = ?",
                new String[] {
                    Long.toString(contactId)
                }, null);
        while (pCur.moveToNext()) {
            phones.add(new Phone(
                    pCur.getString(pCur.getColumnIndex(Phones.NUMBER))
                    , pCur.getString(pCur.getColumnIndex(Phones.TYPE))
                    ));
        }
        pCur.close();
    }
    return (phones);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:21,代码来源:ContactsUtils3.java

示例2: bindContactPhoneView

import android.provider.Contacts.Phones; //导入依赖的package包/类
@Override
public void bindContactPhoneView(View view, Context context, Cursor cursor) {
    
    // Get values
    String value = cursor.getString(cursor.getColumnIndex(Phones.NUMBER));
    String displayName = cursor.getString(cursor.getColumnIndex(Phones.DISPLAY_NAME));
    Long peopleId = cursor.getLong(cursor.getColumnIndex(Phones.PERSON_ID));
    Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, peopleId);
    Bitmap bitmap = getContactPhoto(context, uri, false, R.drawable.ic_contact_picture_holo_dark);
    
    // Get views
    TextView tv = (TextView) view.findViewById(R.id.name);
    TextView sub = (TextView) view.findViewById(R.id.number);
    TextView label = (TextView) view.findViewById(R.id.label);
    ImageView imageView = (ImageView) view.findViewById(R.id.contact_photo);
    
    // Bind
    label.setVisibility(View.GONE);
    view.setTag(value);
    tv.setText(displayName);
    sub.setText(value);
    imageView.setImageBitmap(bitmap);        
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:24,代码来源:ContactsUtils3.java

示例3: bindView

import android.provider.Contacts.Phones; //导入依赖的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

示例4: isExcludedType

import android.provider.Contacts.Phones; //导入依赖的package包/类
boolean isExcludedType(Vector<Integer> vExTypesCode, String sNumber, Context oContext)
  {
  	Uri contactRef = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL, sNumber);
  	final String[] PHONES_PROJECTION = new String[] 
   {
       People.Phones.NUMBER, // 0
       People.Phones.TYPE, // 1
   };
      Cursor phonesCursor = oContext.getContentResolver().query(contactRef, PHONES_PROJECTION, null, null,
              null);
if (phonesCursor != null) 
      {	        			
           while (phonesCursor.moveToNext()) 
          { 			            	
              final int type = phonesCursor.getInt(1);	              
              if(vExTypesCode.contains(Integer.valueOf(type)))
              	return true;	    
          }
          phonesCursor.close();
      }
return false;
  }
 
开发者ID:bigbn,项目名称:phonty,代码行数:23,代码来源:Caller.java

示例5: getContactsPhones

import android.provider.Contacts.Phones; //导入依赖的package包/类
@Override
public Cursor getContactsPhones(Context ctxt, CharSequence constraint) {
    Uri uri = Phones.CONTENT_URI;
    String selection = String.format("%s LIKE ? OR %s LIKE ?", Phones.NUMBER,
            Phones.DISPLAY_NAME);
    String[] selectionArgs = new String[] {
            constraint + "%", "%" + constraint + "%"
    };
    Cursor resCursor = ctxt.getContentResolver().query(uri, PROJECTION_PHONE, selection, selectionArgs,
            Phones.DISPLAY_NAME + " ASC");
    return resCursor;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:13,代码来源:ContactsUtils3.java

示例6: convertToString

import android.provider.Contacts.Phones; //导入依赖的package包/类
@Override
public final CharSequence convertToString(Cursor cursor) {
    String name = cursor.getString(RecipientsAdapter.NAME_INDEX);
    int type = cursor.getInt(RecipientsAdapter.TYPE_INDEX);
    String number = cursor.getString(RecipientsAdapter.NUMBER_INDEX).trim();

    String label = cursor.getString(RecipientsAdapter.LABEL_INDEX);
    CharSequence displayLabel = Phones.getDisplayLabel(mContext, type, label);

    if (number.length() == 0) {
        return number;
    }

    SpannableString out = new SpannableString(RecipientList.Recipient.buildNameAndNumber(name, number));
    int len = out.length();

    if (!TextUtils.isEmpty(name)) {
        out.setSpan(new Annotation("name", name), 0, len,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        out.setSpan(new Annotation("name", number), 0, len,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    String person_id = cursor.getString(RecipientsAdapter.PERSON_ID_INDEX);
    out.setSpan(new Annotation("person_id", person_id), 0, len,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    out.setSpan(new Annotation("label", displayLabel.toString()), 0, len,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    out.setSpan(new Annotation("number", number), 0, len,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    return out;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:35,代码来源:RecipientsAdapter.java

示例7: generatePhoneShortcut

import android.provider.Contacts.Phones; //导入依赖的package包/类
/**
 * Returns an Intent describing a direct text message shortcut.
 *
 * @param result The result from the phone number picker
 * @return an Intent describing a phone number shortcut
 */
private Intent generatePhoneShortcut(Intent result, int actionResId, String scheme, String action) {
    Uri phoneUri = result.getData();
    long personId = 0;
    String name = null;
    String number = null;
    int type;
    Cursor cursor = getContentResolver().query(phoneUri,
            new String[] { Phones.PERSON_ID, Phones.DISPLAY_NAME, Phones.NUMBER, Phones.TYPE },
            null, null, null);
    try {
        cursor.moveToFirst();
        personId = cursor.getLong(0);
        name = cursor.getString(1);
        number = cursor.getString(2);
        type = cursor.getInt(3);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    Intent intent = new Intent();
    Uri personUri = ContentUris.withAppendedId(People.CONTENT_URI, personId);
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON,
            generatePhoneNumberIcon(personUri, type, actionResId));

    // Make the URI a direct tel: URI so that it will always continue to work
    phoneUri = Uri.fromParts(scheme, number, null);
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(action, phoneUri));
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
    return intent;
}
 
开发者ID:tgmarinho,项目名称:apps-for-android,代码行数:38,代码来源:CreateShortcutActivity.java

示例8: findCallerInfo

import android.provider.Contacts.Phones; //导入依赖的package包/类
@Override
public CallerInfo findCallerInfo(Context ctxt, String number) {
    Uri searchUri = Uri
            .withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(number));

    CallerInfo callerInfo = new CallerInfo();

    Cursor cursor = ctxt.getContentResolver().query(searchUri, null, null, null, null);
    if (cursor != null) {
        try {
            if (cursor.getCount() > 0) {
                cursor.moveToFirst();
                ContentValues cv = new ContentValues();
                DatabaseUtils.cursorRowToContentValues(cursor, cv);
                callerInfo.contactExists = true;
                if (cv.containsKey(Phones.DISPLAY_NAME)) {
                    callerInfo.name = cv.getAsString(Phones.DISPLAY_NAME);
                }

                callerInfo.phoneNumber = cv.getAsString(Phones.NUMBER);

                if (cv.containsKey(Phones.TYPE)
                        && cv.containsKey(Phones.LABEL)) {
                    callerInfo.numberType = cv.getAsInteger(Phones.TYPE);
                    callerInfo.numberLabel = cv.getAsString(Phones.LABEL);
                    callerInfo.phoneLabel = Phones.getDisplayLabel(ctxt,
                            callerInfo.numberType, callerInfo.numberLabel)
                            .toString();
                }

                if (cv.containsKey(Phones.PERSON_ID)) {
                    callerInfo.personId = cv.getAsLong(Phones.PERSON_ID);
                    callerInfo.contactContentUri = ContentUris.withAppendedId(
                            People.CONTENT_URI, callerInfo.personId);
                }

                if (cv.containsKey(Phones.CUSTOM_RINGTONE)) {
                    String ringtoneUriString = cv.getAsString(Phones.CUSTOM_RINGTONE);
                    if (!TextUtils.isEmpty(ringtoneUriString)) {
                        callerInfo.contactRingtoneUri = Uri.parse(ringtoneUriString);
                    }
                }

                if (callerInfo.name != null && callerInfo.name.length() == 0) {
                    callerInfo.name = null;
                }

            }

        } catch (Exception e) {
            Log.e(THIS_FILE, "Exception while retrieving cursor infos", e);
        } finally {
            cursor.close();
        }

    }

    // if no query results were returned with a viable number,
    // fill in the original number value we used to query with.
    if (TextUtils.isEmpty(callerInfo.phoneNumber)) {
        callerInfo.phoneNumber = number;
    }

    return callerInfo;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:66,代码来源:ContactsUtils3.java

示例9: runQueryOnBackgroundThread

import android.provider.Contacts.Phones; //导入依赖的package包/类
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    String wherePhone = null;
    String whereEmail = null;
    String phone = "";
    String cons = null;

    if (constraint != null) {
        cons = constraint.toString();

        if (usefulAsDigits(cons)) {
            phone = PhoneNumberUtils.convertKeypadLettersToDigits(cons);
            if (phone.equals(cons)) {
                phone = "";
            } else {
                phone = phone.trim();
            }
        }

        String filter = DatabaseUtils.sqlEscapeString(cons + '%');
        String filterLastName = DatabaseUtils.sqlEscapeString("% " + cons + '%');

        StringBuilder s = new StringBuilder();
        s.append("((name LIKE ");
        s.append(filter);
        s.append(") OR (name LIKE ");
        s.append(filterLastName);
        s.append(") OR (REPLACE(REPLACE(REPLACE(REPLACE(number, ' ', ''), '(', ''), ')', ''), '-', '') LIKE ");
        s.append(filter);
        s.append(")) AND type = ");
        s.append(Phones.TYPE_MOBILE);
        wherePhone = s.toString();

        /*s.delete(0, s.length()); // Clear the string builder.
        s.append("((name LIKE ");
        s.append(filter);
        s.append(") OR (data LIKE ");
        s.append(filter);
        s.append(")) AND kind = ");
        s.append(Contacts.KIND_EMAIL);
        whereEmail = s.toString();*/
    }

    Cursor phoneCursor = SqliteWrapper.query(mContext, mContentResolver,
            Phones.CONTENT_URI, PROJECTION_PHONE, wherePhone, null, SORT_ORDER);
    /*Cursor emailCursor = SqliteWrapper.query(mContext, mContentResolver,
            ContactMethods.CONTENT_URI, PROJECTION_EMAIL, whereEmail, null, SORT_ORDER);*/

    if (phone.length() > 0) {
        ArrayList result = new ArrayList();
        result.add(Integer.valueOf(-1));                    // ID
        result.add(Long.valueOf(-1));                       // PERSON_ID
        result.add(Integer.valueOf(Phones.TYPE_CUSTOM));    // TYPE
        result.add(phone);                                  // NUMBER

        /*
         * The "\u00A0" keeps Phones.getDisplayLabel() from deciding
         * to display the default label ("Home") next to the transformation
         * of the letters into numbers.
         */
        result.add("\u00A0");                               // LABEL
        result.add(cons);                                   // NAME

        ArrayList<ArrayList> wrap = new ArrayList<ArrayList>();
        wrap.add(result);

        ArrayListCursor translated = new ArrayListCursor(PROJECTION_PHONE, wrap);

        return new MergeCursor(new Cursor[] { translated, phoneCursor/*, emailCursor*/ });
    } else {
        return new MergeCursor(new Cursor[] { phoneCursor/*, emailCursor*/ });
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:74,代码来源:RecipientsAdapter.java

示例10: getPhoneProjection

import android.provider.Contacts.Phones; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static String[] getPhoneProjection() {
    return NEW_CONTACT_API  ?
          new String[] { Contacts._ID, Contacts.DISPLAY_NAME } :
          new String[] { Phones.PERSON_ID, People.NAME, Phones.NUMBER };
}
 
开发者ID:zhenlonghe,项目名称:fnzy,代码行数:7,代码来源:CursorToMessage.java


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