zoukankan      html  css  js  c++  java
  • 判断是否为SIM卡联系人

    判断是否为SIM卡联系人

    在AsyncQueryContacts类中。

    private List<TxrjAccount> accounts = new ArrayList<TxrjAccount>();
    private HashMap<Integer, TxrjAccount> accountMap = new HashMap<Integer, TxrjAccount>();

    public AsyncQueryContacts(ContentResolver cr) {
        super(cr);
        initAccounts();
    }

    private void initAccounts() {
        Cursor cursor = mContext.getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI,
                new String[] {RawContacts._ID, RawContacts.ACCOUNT_NAME, RawContacts.ACCOUNT_TYPE },
                null, null, null);
        if (cursor != null) {
            TxrjAccount account = null;
            while (cursor.moveToNext()) {
                int id = cursor.getInt(cursor.getColumnIndex(RawContacts._ID));
                String name = cursor.getString(cursor.getColumnIndex(RawContacts.ACCOUNT_NAME));
                String type = cursor.getString(cursor.getColumnIndex(RawContacts.ACCOUNT_TYPE));
                account = new TxrjAccount(id, name, type);
                accounts.add(account);
                accountMap.put(id, account);
            }
            cursor.close();
        }
    }

    在AsyncQueryContacts.onQueryComplete()方法中。

    if(contact.getPhoneList().size() == 1){
        contact.setbSim(accountMap.get(phone.getRawContactId()).isSimAccount());
    }

    在TxrjAccount类中。

    public static final String PHONE_ACCOUNT_NAME = "vnd.sec.contact.phone";
    public static final String PHONE_ACCOUNT_TYPE = "vnd.sec.contact.phone";
    public static final String SIM2_ACCOUNT_NAME = "primary.sim2.account_name";
    public static final String SIM2_ACCOUNT_TYPE = "vnd.sec.contact.sim2";
    public static final String SIM_ACCOUNT_NAME = "primary.sim.account_name";
    public static final String SIM_ACCOUNT_TYPE = "vnd.sec.contact.sim";

    public boolean isSimAccount() {
        if(type.equals(SIM_ACCOUNT_TYPE) || type.equals(SIM2_ACCOUNT_TYPE)) {
            return true;
        } else {
            return false;
        }
    }

  • 相关阅读:
    JProfiler9安装 监控Tomcat
    linux 大量的TIME_WAIT解决办法(转)
    C2 CompilerThread0 如果抓到的java线程dump里占用CPU最高的线程是这个,99%可能是因为服务重启了
    什么是多线程,锁,死锁,怎么避免死锁(转)
    Jmeter BeanShell 引用变量报错jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Parse error at line 14, column 181 : Error or number too big for integer
    小缘的游戏
    Bad Hair Day
    779A Pupils Redistribution
    Stripies
    校赛-种树
  • 原文地址:https://www.cnblogs.com/fengzhblog/p/3182540.html
Copyright © 2011-2022 走看看