1.启动SIM联系人导入手机INTENT
// SIM import
Intent importIntent = new Intent(Intent.ACTION_VIEW);
importIntent.setType("vnd.android.cursor.item/sim-contact");
importIntent.setClassName("com.android.phone",
"com.android.phone.SimContacts");
startActivity(importIntent);
2.读取SIM卡联系人
Cursor cursor = getSIMContacts();
while (cursor != null && cursor.moveToNext()) {
String name = cursor.getString(cursor
.getColumnIndex("name"));
String number = cursor.getString(cursor
.getColumnIndex("number"));
}
private Cursor getSIMContacts() {
// Run query
Uri uri = Uri.parse("content://icc/adn");// Contacts.People.CONTENT_URI;
// Uri uri = Uri.parse("content://sim/adn");
String[] projection = new String[] { "name", "phone" };
String selection = null;
String[] selectionArgs = null;
String sortOrder = "name"// Contacts.People.NAME//
// Contacts.PeopleColumns.DISPLAY_NAME
+ " COLLATE LOCALIZED ASC";
return managedQuery(uri, projection, selection, selectionArgs,
sortOrder);
// SIM import
Intent importIntent = new Intent(Intent.ACTION_VIEW);
importIntent.setType("vnd.android.cursor.item/sim-contact");
importIntent.setClassName("com.android.phone",
"com.android.phone.SimContacts");
startActivity(importIntent);
2.读取SIM卡联系人
Cursor cursor = getSIMContacts();
while (cursor != null && cursor.moveToNext()) {
String name = cursor.getString(cursor
.getColumnIndex("name"));
String number = cursor.getString(cursor
.getColumnIndex("number"));
}
private Cursor getSIMContacts() {
// Run query
Uri uri = Uri.parse("content://icc/adn");// Contacts.People.CONTENT_URI;
// Uri uri = Uri.parse("content://sim/adn");
String[] projection = new String[] { "name", "phone" };
String selection = null;
String[] selectionArgs = null;
String sortOrder = "name"// Contacts.People.NAME//
// Contacts.PeopleColumns.DISPLAY_NAME
+ " COLLATE LOCALIZED ASC";
return managedQuery(uri, projection, selection, selectionArgs,
sortOrder);
}
转来的