현재 연락처 앱에서 작업 중이며 잠시 동안 Android에서 프로그래밍 방식으로 연락처를 검색하고 있습니다. 어떤 형식으로 다른 장치에 연락처를 보내야할지 몰랐습니다. 내가 텍스트로 보내는 경우, 그것은 receivers 장치에서 contactscontract Db로 어떻게 처리 될 것입니까? 어떻게 작동하게 만드시겠습니까?안드로이드에서 프로그램 방식으로 연락처를 공유하는 방법
0
A
답변
1
whatsapps와 (과) 무언가를 공유하는 방법을 묻는다면 그 내용과 의도를 보내보십시오.
이 같은 일반 텍스트를 보낼 수 있습니다
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
try {
activity.startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
ToastHelper.MakeShortText("Whatsapp have not been installed.");
}
은 자세한 내용은 Share image and text through Whatsapp or Facebook를 참조하십시오.
당신은 더 후, 나는 당신이 WhatsApp
은 또한 더 일반적인 정보는 this page of Android
에서 찾을 수 있습니다에 대한 같은 분 파티 개발 문서를 살펴 보시기 바랍니다 있음을 이동하려면 Here은 의도적으로 보낼 수있는 것의 개요입니다. 다음 ACTION_SEND
의도를 사용하여 보내
1
당신은 (Contacts.CONTENT_VCARD_URI
ContactsContract
API를 사용하여) 연락처의 VCard
핸들을 얻을 필요가있다.
String lookupKey = <the contact's lookup key>;
Uri vcardUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType(ContactsContract.Contacts.CONTENT_VCARD_TYPE);
intent.putExtra(Intent.EXTRA_STREAM, shareUri);
intent.putExtra(Intent.EXTRA_SUBJECT, "Bob Dylan"); // put the name of the contact here
startActivity(intent);
여기에 대한 자세한 내용보기 :
https://developer.android.com/reference/android/provider/ContactsContract.Contacts.html#CONTENT_VCARD_URI
UPDATE
가 @Abhay Maniyar에 의해 삭제 된 질문에 대답 - contactId를에서 lookupKey를 얻을 :
Cursor cur = getContentResolver().query(Contacts.CONTENT_URI, new String[] { Contacts.LOOKUP_KEY }, Contacts._ID + " = " + contactId, null, null);
if (cur.moveToFirst()) {
String lookupKey = cur.getString(0);
}
0
다음 코드를 사용하여 공동 작업을 공유하십시오. 의 ntact, 미트 커서
private void shareContact() {
//lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
String lookupKey2 = lookupKey;
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey2);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType(ContactsContract.Contacts.CONTENT_VCARD_TYPE);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.putExtra(Intent.EXTRA_SUBJECT, contactName); // put the name of the contact here
startActivity(intent);
}
감사 @Raymond 드 라 크로에서 담당자 이름 및 LookupKey를 얻을! 나는 이것을 시험해 볼 것이다! – Kanagalingam
Goodluck :) 나는 안드로이드에서 또 다른 참조 사이트를 추가했다.이 사이트는 모든 보내기 유형을 보여 주며, 이는 도움이 될 것이다. –