本文整理匯總了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
};
}