android SIM联系人(转)

一、启动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.         }  

 

阅读更多
个人分类: android UI
想对作者说点什么? 我来说一句

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

不良信息举报

android SIM联系人(转)

最多只允许输入30个字

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