public static final int COLUMN_INDEX_DISPLAYNAME = 1;    public static final int COLUMN_INDEX_SEARCHENUMBER = 2;    public static final String SEARCH_URL = "content://com.android.contacts/search_suggest_query/";        public static ArrayList searchContactsWithSuggest(Context context, String suggest) {        Cursor cursor = null;        ArrayList contacts = null;        try {            Uri uri = Uri.parse(SEARCH_URL + suggest + "?limit=100");            cursor = context.getContentResolver().query(uri, null, null, null, null);            if (cursor != null) {                contacts = new ArrayList();                cursor.moveToPosition(-1);                while (cursor.moveToNext()) {                    String displayName = cursor.getString(COLUMN_INDEX_DISPLAYNAME);                    String number = cursor.getString(COLUMN_INDEX_SEARCHENUMBER);                    ContactInfo info = new ContactInfo(ContactInfo.TYPE_CONTACT, 0, 0, displayName, null, null, false);                    DataBean dataBean = new DataBean(ContactInfo.TYPE_CONTACT, number);                    DataBean[] list = new DataBean[] { dataBean };                    info.setDataBeans(list);                    contacts.add(info);                }            }        } catch (Exception e) {            e.printStackTrace();        } finally {            if (cursor != null) {                cursor.close();            }        }        return contacts;    }   

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android(安卓)在TextView 中显示图片的4
  2. 学习Android之-----------------------An
  3. Android Lint & Checkstyle
  4. Android 启动栈管理方式 (二)
  5. Kotlin语言概述2
  6. 【Android】Android apk默认安装位置设置
  7. android:textAppearance是什么意思
  8. Android图片太大导致无法正常显示
  9. Android(安卓)NDK学习(2)Windows下NDK开发
  10. android ellipsize的使用