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.         }  

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值