本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.Phone.LABEL属性的典型用法代码示例。如果您正苦于以下问题:Java Phone.LABEL属性的具体用法?Java Phone.LABEL怎么用?Java Phone.LABEL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.ContactsContract.CommonDataKinds.Phone
的用法示例。
在下文中一共展示了Phone.LABEL属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
@Override
protected Void doInBackground(Long... ids) {
String[] projection = new String[] {Phone.DISPLAY_NAME, Phone.TYPE, Phone.NUMBER, Phone.LABEL};
long contactId = ids[0];
final Cursor phoneCursor = getActivity().getContentResolver().query(
Phone.CONTENT_URI,
projection,
Data.CONTACT_ID + "=?",
new String[]{String.valueOf(contactId)},
null);
if(phoneCursor != null && phoneCursor.moveToFirst() && phoneCursor.getCount() == 1) {
final int contactNumberColumnIndex = phoneCursor.getColumnIndex(Phone.NUMBER);
mPhoneNumber = phoneCursor.getString(contactNumberColumnIndex);
int type = phoneCursor.getInt(phoneCursor.getColumnIndexOrThrow(Phone.TYPE));
mPhoneLabel = phoneCursor.getString(phoneCursor.getColumnIndex(Phone.LABEL));
mPhoneLabel = Phone.getTypeLabel(getResources(), type, mPhoneLabel).toString();
phoneCursor.close();
}
return null;
}
示例2: onActivityCreated
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
long personId = getArguments().getLong(ContactsPickerActivity.SELECTED_CONTACT_ID);// getIntent().getLongExtra("id", 0);
Activity activity = getActivity();
Uri phonesUri = Phone.CONTENT_URI;
String[] projection = new String[] {
Phone._ID, Phone.DISPLAY_NAME,
Phone.TYPE, Phone.NUMBER, Phone.LABEL };
String selection = Phone.CONTACT_ID + " = ?";
String[] selectionArgs = new String[] { Long.toString(personId) };
mCursor = activity.getContentResolver().query(phonesUri,
projection, selection, selectionArgs, null);
mDisplayName = (TextView) activity.findViewById(R.id.display_name);
if (mCursor.moveToFirst()){
mDisplayName.setText(mCursor.getString(mCursor.getColumnIndex(Phone.DISPLAY_NAME)));
}
ListAdapter adapter = new PhoneNumbersAdapter(this.getActivity(),
R.layout.list_item_phone_number, mCursor,
new String[] {Phone.TYPE, Phone.NUMBER },
new int[] { R.id.label, R.id.phone_number });
setListAdapter(adapter);
}
示例3: runQueryOnBackgroundThread
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
String constraintPath = null;
if (constraint != null) {
constraintPath = constraint.toString();
}
Uri queryURI = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI,
Uri.encode(constraintPath));
String[] projection = { Phone._ID, Phone.CONTACT_ID, Phone.DISPLAY_NAME,
Phone.NUMBER, Phone.TYPE, Phone.LABEL, };
// default: all numbers
String selection = null;
String[] selectionArgs = null;
String filter = preferences.getString("filter_receiver", "");
if (filter.contains("M")) { // mobiles only
selection = Phone.TYPE + "=? OR " + Phone.TYPE + "=?";
selectionArgs = new String[] {
String.valueOf(Phone.TYPE_MOBILE),
String.valueOf(Phone.TYPE_WORK_MOBILE)};
}
if (filter.contains("H")) { // no home numbers
selection = Phone.TYPE + "<>?";
selectionArgs = new String[] { String.valueOf(Phone.TYPE_HOME) };
}
String sortOrder = Contacts.TIMES_CONTACTED + " DESC";
return context.getContentResolver()
.query(queryURI, projection, selection, selectionArgs, sortOrder);
}
示例4: getContacts
private Cursor getContacts() {
// Run query
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] { ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.HAS_PHONE_NUMBER, Phone.NUMBER,
Phone.TYPE, Phone.LABEL };
String selection;
/*
* selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" +
* (mShowInvisible ? "0" : "1") + "' AND "+
* ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '1'";
*/
selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '1'";
String[] selectionArgs = null;
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
+ " COLLATE LOCALIZED ASC";
// return managedQuery(uri, projection, selection, selectionArgs,
// sortOrder);
return mContext.getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, selection, null,
sortOrder);
}
示例5: getContacts
/**
* Obtains the contact list for the currently selected account.
*
* @return A cursor for for accessing the contact list.
*/
private Cursor getContacts(String constraint) {
// Run query
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.HAS_PHONE_NUMBER,
Phone.NUMBER,Phone.TYPE, Phone.LABEL };
String selection = null;
/*
* selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" +
* (mShowInvisible ? "0" : "1") + "' AND "+
* ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '1'";
*/
selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '1'";
if (constraint!=null && constraint.length()>0) {
selection += " AND lower("+ContactsContract.Contacts.DISPLAY_NAME + ") like '%" + constraint +"%' COLLATE NOCASE";
}
String[] selectionArgs = null;
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
+ " COLLATE LOCALIZED ASC";
Cursor result = getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, selection,
selectionArgs, sortOrder);
return result;
}
示例6: lookupContactNumbersFor
/**
* Lookup the numbers for a given contact.
*
* Usually this is not needed because most methods already return the
* contacts with all known contact numbers. Make sure to call
* {@link #contactsReadModuleInstalled()} first.
*
* @param contact
*/
public void lookupContactNumbersFor(Contact contact) {
if (!contactsReadModuleInstalled()) return;
String lookupKey = contact.getLookupKey();
// @formatter:off
final String[] projection = new String[] {
Phone.NUMBER,
Phone.TYPE,
Phone.LABEL,
Phone.IS_SUPER_PRIMARY
};
// @formatter:on
final String selection = ContactsContract.PhoneLookup.LOOKUP_KEY + "=?" + AND
+ ContactsContract.Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'";
final String[] selectionArgs = new String[] { lookupKey };
Cursor c = mContentResolver.query(MAXS_DATA_CONTENT_URI, projection, selection,
selectionArgs, null);
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
String number = c.getString(c
.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
int type = c.getInt(c
.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.TYPE));
String label = c.getString(c
.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.LABEL));
boolean superPrimary = c
.getInt(c
.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY)) > 0 ? true
: false;
contact.addNumber(number, type, label, superPrimary);
}
c.close();
}
示例7: getCursorForRecipientFilter
/***
* If the code below looks shitty to you, that's because it was taken
* directly from the Android source, where shitty code is all you get.
*/
public Cursor getCursorForRecipientFilter(CharSequence constraint,
ContentResolver mContentResolver)
{
final String SORT_ORDER = Contacts.TIMES_CONTACTED + " DESC," +
Contacts.DISPLAY_NAME + "," +
Contacts.Data.IS_SUPER_PRIMARY + " DESC," +
Phone.TYPE;
final String[] PROJECTION_PHONE = {
Phone._ID, // 0
Phone.CONTACT_ID, // 1
Phone.TYPE, // 2
Phone.NUMBER, // 3
Phone.LABEL, // 4
Phone.DISPLAY_NAME, // 5
};
String phone = "";
String cons = null;
if (constraint != null) {
cons = constraint.toString();
if (RecipientsAdapter.usefulAsDigits(cons)) {
phone = PhoneNumberUtils.convertKeypadLettersToDigits(cons);
if (phone.equals(cons) && !PhoneNumberUtils.isWellFormedSmsAddress(phone)) {
phone = "";
} else {
phone = phone.trim();
}
}
}
Uri uri = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(cons));
String selection = String.format("%s=%s OR %s=%s OR %s=%s",
Phone.TYPE,
Phone.TYPE_MOBILE,
Phone.TYPE,
Phone.TYPE_WORK_MOBILE,
Phone.TYPE,
Phone.TYPE_MMS);
Cursor phoneCursor = mContentResolver.query(uri,
PROJECTION_PHONE,
null,
null,
SORT_ORDER);
if (phone.length() > 0) {
ArrayList result = new ArrayList();
result.add(Integer.valueOf(-1)); // ID
result.add(Long.valueOf(-1)); // CONTACT_ID
result.add(Integer.valueOf(Phone.TYPE_CUSTOM)); // TYPE
result.add(phone); // NUMBER
/*
* The "\u00A0" keeps Phone.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 });
} else {
return phoneCursor;
}
}
示例8: getCursorForRecipientFilter
/***
* If the code below looks shitty to you, that's because it was taken
* directly from the Android source, where shitty code is all you get.
*/
public Cursor getCursorForRecipientFilter(CharSequence constraint,
ContentResolver mContentResolver)
{
final String SORT_ORDER = Contacts.TIMES_CONTACTED + " DESC," +
Contacts.DISPLAY_NAME + "," +
Contacts.Data.IS_SUPER_PRIMARY + " DESC," +
Phone.TYPE;
final String[] PROJECTION_PHONE = {
Phone._ID, // 0
Phone.CONTACT_ID, // 1
Phone.TYPE, // 2
Phone.NUMBER, // 3
Phone.LABEL, // 4
Phone.DISPLAY_NAME, // 5
};
String phone = "";
String cons = null;
if (constraint != null) {
cons = constraint.toString();
if (RecipientsAdapter.usefulAsDigits(cons)) {
phone = PhoneNumberUtils.convertKeypadLettersToDigits(cons);
if (phone.equals(cons) && !PhoneNumberUtils.isWellFormedSmsAddress(phone)) {
phone = "";
} else {
phone = phone.trim();
}
}
}
Uri uri = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(cons));
String selection = String.format("%s=%s OR %s=%s OR %s=%s",
Phone.TYPE,
Phone.TYPE_MOBILE,
Phone.TYPE,
Phone.TYPE_WORK_MOBILE,
Phone.TYPE,
Phone.TYPE_MMS);
Cursor phoneCursor = mContentResolver.query(uri,
PROJECTION_PHONE,
null,
null,
SORT_ORDER);
if (phone.length() > 0) {
ArrayList result = new ArrayList();
result.add(Integer.valueOf(-1)); // ID
result.add(Long.valueOf(-1)); // CONTACT_ID
result.add(Integer.valueOf(Phone.TYPE_CUSTOM)); // TYPE
result.add(phone); // NUMBER
/*
* The "\u00A0" keeps Phone.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 });
} else {
return phoneCursor;
}
}
示例9: getProjPhone
@Override
public String[] getProjPhone() {
return new String[] {
Phone.MIMETYPE, Phone.NUMBER, Phone.TYPE, Phone.IS_PRIMARY, Phone.LABEL
};
}