zoukankan      html  css  js  c++  java
  • 根据指定*得到通讯录上的姓名

    public String getPeople(String mNumber) { 
    String name = "";
            String[] projection = { ContactsContract.PhoneLookup.DISPLAY_NAME,  
                                    /*ContactsContract.CommonDataKinds.Phone.NUMBER*/};  
        
        Cursor cursor = this.getContentResolver().query(  
                    ContactsContract.CommonDataKinds.Phone.CONTENT_URI,  
                    projection,      
                ContactsContract.CommonDataKinds.Phone.NUMBER + " = '" + mNumber + "'",  
                    null,           
                    null);   
            if( cursor == null ) {  
                return "";  
        }  
            for( int i = 0; i < cursor.getCount(); i++ )  
            {  
            cursor.moveToPosition(i);  
                
                int nameFieldColumnIndex = cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME);  
    cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME);    
                name = cursor.getString(nameFieldColumnIndex);  
                Log.i(TAG, "lanjianlong" + name + " .... " + nameFieldColumnIndex); // 这里提示 force close  
             break;
            }  
            if(cursor != null){
            cursor.close();
            }
            return name;
    }  

  • 相关阅读:
    python笔记1
    git笔记
    手撸一个简陋直播系统
    spring-boot学习笔记1
    设计模式1--简单工厂模式
    网联:第一章:浏览器生成消息
    php线上预览日志--4.websocket客户端
    php线上预览日志--3.websocket服务部署
    php线上预览日志--2.谷歌插件开发
    php线上预览日志--1.概述
  • 原文地址:https://www.cnblogs.com/riskyer/p/3278425.html
Copyright © 2011-2022 走看看