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


Java Phone.TYPE属性代码示例

本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.Phone.TYPE属性的典型用法代码示例。如果您正苦于以下问题:Java Phone.TYPE属性的具体用法?Java Phone.TYPE怎么用?Java Phone.TYPE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.provider.ContactsContract.CommonDataKinds.Phone的用法示例。


在下文中一共展示了Phone.TYPE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:vaslabs,项目名称:SDC,代码行数:23,代码来源:ContactsListFragment.java

示例2: matchContactNumbers

public void matchContactNumbers(Map<String, Contact> contactsMap) {
    // Get numbers
    final String[] numberProjection = new String[]{
            Phone.NUMBER,
            Phone.TYPE,
            Phone.CONTACT_ID,
    };

    Cursor phone = new CursorLoader(context,
            Phone.CONTENT_URI,
            numberProjection,
            null,
            null,
            null).loadInBackground();

    if (phone.moveToFirst()) {
        final int contactNumberColumnIndex = phone.getColumnIndex(Phone.NUMBER);
        final int contactTypeColumnIndex = phone.getColumnIndex(Phone.TYPE);
        final int contactIdColumnIndex = phone.getColumnIndex(Phone.CONTACT_ID);

        while (!phone.isAfterLast()) {
            final String number = phone.getString(contactNumberColumnIndex);
            final String contactId = phone.getString(contactIdColumnIndex);
            Contact contact = contactsMap.get(contactId);
            if (contact == null) {
                continue;
            }
            final int type = phone.getInt(contactTypeColumnIndex);
            String customLabel = "Custom";
            CharSequence phoneType = ContactsContract.CommonDataKinds.Phone.getTypeLabel(context.getResources(), type, customLabel);
            contact.addNumber(number, phoneType.toString());
            phone.moveToNext();
        }
    }

    phone.close();
}
 
开发者ID:amit-upadhyay-IT,项目名称:contacts-search-android,代码行数:37,代码来源:ContactFetcher.java

示例3: getDataProjection

/**
 * Get the DATA_PROJECTION for ContactPicker and PhoneNumberPicker.
 */
public static String[] getDataProjection() {
  String[] dataProjection = {
    Data.MIMETYPE,
    Email.ADDRESS,
    Email.TYPE,
    Phone.NUMBER,
    Phone.TYPE,
  };
  return dataProjection;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:13,代码来源:HoneycombMR1Util.java

示例4: runQueryOnBackgroundThread

/**
 * {@inheritDoc}
 */
@Override
public final Cursor runQueryOnBackgroundThread(final CharSequence constraint) {
    String s = constraint == null ? null : constraint.toString();
    String where = prefsMobilesOnly ? Phone.TYPE + " = " + Phone.TYPE_MOBILE + " OR "
            + Phone.TYPE + " = " + Phone.TYPE_WORK_MOBILE : null;
    Uri u = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(s));
    Cursor cursor = mContentResolver.query(u, PROJECTION, where, null, Phone.DISPLAY_NAME);
    return cursor;
}
 
开发者ID:andrewxu10,项目名称:Upkeep,代码行数:12,代码来源:MobilePhoneAdapter.java

示例5: 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);
}
 
开发者ID:vaslabs,项目名称:SDC,代码行数:28,代码来源:ContactDetailsFragment.java

示例6: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get a cursor with all phones
    Cursor c = getContentResolver().query(Phone.CONTENT_URI,
            PHONE_PROJECTION, null, null, null);
    startManagingCursor(c);

    // Map Cursor columns to views defined in simple_list_item_2.xml
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
            android.R.layout.simple_list_item_2, c,
                    new String[] {
                        Phone.TYPE,
                        Phone.NUMBER
                    },
                    new int[] { android.R.id.text1, android.R.id.text2 });
    //Used to display a readable string for the phone type
    adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            //Let the adapter handle the binding if the column is not TYPE
            if (columnIndex != COLUMN_TYPE) {
                return false;
            }
            int type = cursor.getInt(COLUMN_TYPE);
            String label = null;
            //Custom type? Then get the custom label
            if (type == Phone.TYPE_CUSTOM) {
                label = cursor.getString(COLUMN_LABEL);
            }
            //Get the readable string
            String text = (String) Phone.getTypeLabel(getResources(), type, label);
            //Set text
            ((TextView) view).setText(text);
            return true;
        }
    });
    setListAdapter(adapter);
}
 
开发者ID:luoqii,项目名称:ApkLauncher,代码行数:39,代码来源:List3.java

示例7: 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);
}
 
开发者ID:adepasquale,项目名称:esms,代码行数:35,代码来源:ReceiverAdapter.java

示例8: runQueryOnBackgroundThread

/**
 * {@inheritDoc}
 */
@Override
public final Cursor runQueryOnBackgroundThread(final CharSequence constraint) {
	String s = constraint == null ? null : constraint.toString();
	String where = prefsMobilesOnly ? Phone.TYPE + " = " + Phone.TYPE_MOBILE : null;
	Uri u = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(s));
	Cursor cursor = this.mContentResolver.query(u, PROJECTION, where, null, Phone.DISPLAY_NAME);
	return cursor;
}
 
开发者ID:ericcurtin,项目名称:Fall-Monitor,代码行数:11,代码来源:MobilePhoneAdapter.java

示例9: handleContactResult

private void handleContactResult(final Intent data) {
    final String[] proj = { Phone.NUMBER, Phone.TYPE };
    final Cursor cursor = getActivity().managedQuery(data.getData(), proj, null, null, null);
    if (cursor.moveToFirst()) {
        text.setText(cursor.getString(0));
    }
}
 
开发者ID:Polidea,项目名称:android-menu-navigator,代码行数:7,代码来源:PhoneNumberFragment.java

示例10: 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);

}
 
开发者ID:dmvstar,项目名称:kidsdialer,代码行数:27,代码来源:ContactPrimaryCursorData.java

示例11: 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;
}
 
开发者ID:dmvstar,项目名称:kidsdialer,代码行数:36,代码来源:FavoritesManagerActivity.java

示例12: 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();
}
 
开发者ID:ProjectMAXS,项目名称:maxs,代码行数:42,代码来源:ContactUtil.java

示例13: 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;
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:77,代码来源:ContactAccessor.java

示例14: getMobileNumber

public synchronized Future<String> getMobileNumber(final Context context) {
    if (mNumber != null) {
        return new Present<>(mNumber);
    } else {
        return new FutureImpl<String>() {
            @Override
            public String get() {
                List<String> numbers = new LinkedList<>();

                Uri uri = Phone.CONTENT_URI;
                String[] projection = new String[] {
                        Phone.NUMBER,
                        Phone.IS_PRIMARY,
                        Phone.TYPE
                };
                String clause = Phone.CONTACT_ID + " = ? AND " + Phone.TYPE + " = ?";
                String[] args = new String[] { getId(), Integer.toString(Phone.TYPE_MOBILE) };
                Cursor cursor = context.getContentResolver().query(uri, projection, clause, args, null);
                if (cursor != null) {
                    try {
                        if (cursor.moveToFirst()) {
                            do {
                                boolean isPrimary = cursor.getInt(cursor.getColumnIndex(Phone.IS_PRIMARY)) != 0;
                                String number = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));

                                if (isPrimary) {
                                    numbers.add(0, number);
                                } else {
                                    numbers.add(number);
                                }
                            } while (cursor.moveToNext());
                        }
                    } finally {
                        cursor.close();
                    }
                }
                if (numbers.isEmpty()) {
                    return null;
                } else {
                    return setNumber(numbers.get(0));
                }
            }
        };
    }
}
 
开发者ID:Xlythe,项目名称:AndroidTextManager,代码行数:45,代码来源:Contact.java

示例15: 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;
    }
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:77,代码来源:ContactAccessor.java


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