android.provider.ContactsContract.DataUsageFeedback的实例源码

项目:sms_DualCard    文件RecipientsAdapter.java   
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    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();
            }
        }
    }

    Uri uri = Phone.CONTENT_FILTER_URI.buildUpon()
            .appendpath(cons)
            .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,DataUsageFeedback.USAGE_TYPE_SHORT_TEXT)
            .build();
    /*
     * if we decide to filter based on phone types use a selection
     * like this.
    String selection = String.format("%s=%s OR %s=%s OR %s=%s",Phone.TYPE,Phone.TYPE_MOBILE,Phone.TYPE_WORK_MOBILE,Phone.TYPE_MMS);
     */
    Cursor phoneCursor =
        mContentResolver.query(uri,PROJECTION_PHONE,null,//selection,null);

    if (phone.length() > 0) {
        Object[] result = new Object[7];
        result[0] = Integer.valueOf(-1);                    // ID
        result[1] = Long.valueOf(-1);                       // CONTACT_ID
        result[2] = Integer.valueOf(Phone.TYPE_CUSTOM);     // TYPE
        result[3] = 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[4] = "\u00A0";                               // LABEL
        result[5] = cons;                                   // NAME
        result[6] = phone;                                  // norMALIZED_NUMBER

        MatrixCursor translated = new MatrixCursor(PROJECTION_PHONE,1);
        translated.addRow(result);
        return new MergeCursor(new Cursor[] { translated,phoneCursor });
    } else {
        return phoneCursor;
    }
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...