Java Code Examples for android.provider.ContactsContract.CommonDataKinds.Phone#getTypeLabel()

The following examples show how to use android.provider.ContactsContract.CommonDataKinds.Phone#getTypeLabel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: List7.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
    if (position >= 0) {
        //Get current cursor
        Cursor c = (Cursor) parent.getItemAtPosition(position);
        int type = c.getInt(COLUMN_PHONE_TYPE);
        String phone = c.getString(COLUMN_PHONE_NUMBER);
        String label = null;
        //Custom type? Then get the custom label
        if (type == Phone.TYPE_CUSTOM) {
            label = c.getString(COLUMN_PHONE_LABEL);
        }
        //Get the readable string
        String numberType = (String) Phone.getTypeLabel(getResources(), type, label);
        String text = numberType + ": " + phone;
        mPhone.setText(text);
    }
}
 
Example 2
Source File: SelectContactModule.java    From react-native-select-contact with MIT License 5 votes vote down vote up
private void addPhoneEntry(WritableArray phones, Cursor cursor, Activity activity) {
    String phoneNumber = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));
    int phoneType = cursor.getInt(cursor.getColumnIndex(Phone.TYPE));
    String phoneLabel = cursor.getString(cursor.getColumnIndex(Phone.LABEL));
    CharSequence typeLabel = Phone.getTypeLabel(activity.getResources(), phoneType, phoneLabel);

    WritableMap phoneEntry = Arguments.createMap();
    phoneEntry.putString("number", phoneNumber);
    phoneEntry.putString("type", String.valueOf(typeLabel));

    phones.pushMap(phoneEntry);
}
 
Example 3
Source File: ContactAccessor.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
public CharSequence phoneTypeToString(Context mContext, int type, CharSequence label) {
  return Phone.getTypeLabel(mContext.getResources(), type, label);
}
 
Example 4
Source File: PhoneUtilEclair.java    From DumbphoneAssistant with GNU General Public License v2.0 4 votes vote down vote up
public ArrayList<Contact> get() {
    Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
    String[] projection = new String[] {
            PhoneLookup._ID,
            PhoneLookup.DISPLAY_NAME,
            ContactsContract.CommonDataKinds.Phone.TYPE,
            ContactsContract.CommonDataKinds.Phone.LABEL,
            ContactsContract.CommonDataKinds.Phone.NUMBER
    };
    String[] simTypesQueryParts = new String[simTypes.length];
    Arrays.fill(simTypesQueryParts, ContactsContract.RawContacts.ACCOUNT_TYPE + " <> ?");
    String simTypesQuery = TextUtils.join(" AND ", simTypesQueryParts);
    String selection = ContactsContract.RawContacts.ACCOUNT_TYPE + " IS NULL OR (" + simTypesQuery + ")";
    String[] selectionArgs = simTypes;

    Cursor results = resolver.query(
            uri,
            projection,
            selection,
            selectionArgs,
            null
    );

    // create array of Phone contacts and fill it
    final ArrayList<Contact> phoneContacts = new ArrayList<>();
    int indexId = results.getColumnIndex(PhoneLookup._ID);
    int indexName = results.getColumnIndex(PhoneLookup.DISPLAY_NAME);
    int indexType = results.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE);
    int indexLabel = results.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL);
    int indexNumber = results.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
    while (results.moveToNext()) {
        int type = results.getInt(indexType);
        String custom = results.getString(indexLabel);
        final Contact phoneContact = new Contact(
                results.getString(indexId),
                results.getString(indexName),
                results.getString(indexNumber),
                (String) Phone.getTypeLabel(this.activity.getResources(), type, custom)
        );
        phoneContacts.add(phoneContact);
    }
    results.close();
    return phoneContacts;
}
 
Example 5
Source File: Queries.java    From talk-android with MIT License 4 votes vote down vote up
@Override
public CharSequence getTypeLabel(Resources res, int type, CharSequence label) {
    return Phone.getTypeLabel(res, type, label);
}
 
Example 6
Source File: ContactAccessor.java    From Silence with GNU General Public License v3.0 4 votes vote down vote up
public CharSequence phoneTypeToString(Context mContext, int type, CharSequence label) {
  return Phone.getTypeLabel(mContext.getResources(), type, label);
}
 
Example 7
Source File: Queries.java    From ChipsLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public CharSequence getTypeLabel(final Resources res,final int type,final CharSequence label)
  {
  return Phone.getTypeLabel(res,type,label);
  }