contentReceiver

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Uri uri = ContactsContract.Contacts.CONTENT_URI;
        ContentResolver contentResolver =this.getApplicationContext().getContentResolver();
        Cursor cursor = contentResolver.query(uri,null,null,null,null);
        while (cursor.moveToNext()){
            String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
            String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
            Log.e("TAG", "getContact: --------------id:"+id+"  name:"+name);
        }
        cursor.close();
    }
}
阅读更多
文章标签: contentReceiver
个人分类: Android
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭