关闭

android SIM联系人(转)

标签: androidimportstring手机
402人阅读 评论(1) 收藏 举报
分类:

一、启动SIM联系人导入手机 INTENT

  1. // SIM import   
  2.                                         Intent importIntent = new  Intent(Intent.ACTION_VIEW);  
  3.                                         importIntent.setType("vnd.android.cursor.item/sim-contact" );  
  4.                                         importIntent.setClassName("com.android.phone" ,  
  5.                                                         "com.android.phone.SimContacts" );  
  6.                                         startActivity(importIntent);  

二、读取SIM卡联系人

  1. Cursor cursor = getSIMContacts();  
  2.                                  while  (cursor !=  null  && cursor.moveToNext()) {  
  3.                                  String name = cursor.getString(cursor  
  4.                                                  .getColumnIndex("name" ));  
  5.                                  String number = cursor.getString(cursor  
  6.                                                  .getColumnIndex("number" ));         
  7.                                  }  
  8.         private  Cursor getSIMContacts() {  
  9.                 // Run query   
  10.                 Uri uri = Uri.parse("content://icc/adn" );// Contacts.People.CONTENT_URI;  
  11.                 // Uri uri = Uri.parse("content://sim/adn");   
  12.                 String[] projection = new  String[] {  "name" "phone"  };  
  13.                 String selection = null ;  
  14.                 String[] selectionArgs = null ;  
  15.                 String sortOrder = "name" // Contacts.People.NAME//   
  16.                                 // Contacts.PeopleColumns.DISPLAY_NAME   
  17.                                 + " COLLATE LOCALIZED ASC" ;  
  18.                 return  managedQuery(uri, projection, selection, selectionArgs,  
  19.                                 sortOrder);  
  20.         }  

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:26612次
    • 积分:377
    • 等级:
    • 排名:千里之外
    • 原创:3篇
    • 转载:42篇
    • 译文:0篇
    • 评论:2条
    文章分类
    文章存档
    最新评论