簡體   English   中英

使用意圖將文本共享到whatsapp並獲取共享的聯系人詳細信息

[英]Share text to whatsapp using intent and get shared person contact details

在我的應用程序中,我通過whatsapp共享文本,它將可以正常工作。 但是共享成功后,文本需要從android中的onActivityResult獲取共享的人或共享的組詳細信息。

下面的代碼我嘗試。

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.");
}

需要從Android中的onActivityResult獲取共享的人或共享的組詳細信息

ACTION_SEND不返回結果。 歡迎您致電startActivityForResult() ; 幾乎可以肯定,您不會得到結果。

即使WhatsApp出於某種原因有一個錯誤的ACTION_SEND實現返回了結果,但希望它不包含“共享的人或共享的組詳細信息”,因為這將代表隱私缺陷。

如果WhatsApp具有用於其Android應用程序或通信服務的專用API,則可以考慮使用它們,看看它們是否提供您想要的東西。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM