URI

2013-02-03 4 views
2
에 의해 기본 연락처 카드를 여는 방법을

사람은 내가 의한 접촉 URI를 해결하기 위해 관리하는 특정 연락처에 대한 URIURI

를 접촉 기본을 여는 방법을 설명해 주시겠습니까 이 :

 Intent intent = new Intent(Intent.ACTION_VIEW); 
    intent.setType(ContactsContract.Contacts.CONTENT_TYPE); 
    intent.putExtra(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, "555"); 
    context.startActivity(intent); 

하지만 그것은 단지 어떤

답변

3
,335를 해결하지 않고 기본 주소록을 열려

당신은 contentResolver 사용하여 검색하여 contactId의를 검색 할 수 있습니다

id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); 
name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); 
Log.d(tag, "Id: "+ id+"\t Name: "+name); 
0

당신이 접촉의 cursor 및 특정 연락처의 인덱스를 취득 후, Uri를 얻을 아래 ACTION_VIEW의 목적으로 활동을 시작합니다

cursor.moveToPosition(position); // or cursor.moveToFirst() if single contact was selected. 
long id = cursor.getLong(cursor.getColumnIndex(ContactsContract.Contacts._ID)); 
String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); 
Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setData(ContactsContract.Contacts.getLookupUri(id, lookupKey)); 
try { 
    context.startActivity(intent); 
} catch (Exception e) { 
    e.printStackTrace(); 
} 
관련 문제