如何在Android的Intent帮助下通过Whatsapp从自己的应用程序发送文本消息和图像?

weixin_38087646 2019-09-12 01:16:34
我无法通过whatsapp发送短信和图片.要么,我能够 在没有任何消息的情况下启动该特定联系人聊天线程,或者我只能发送消息但不能打开该特定联系人聊天线程. 我关注了以下链接:http://www.whatsapp.com/faq/en/android/28000012 Sending message through WhatsApp Send Whatsapp message to specific contact 但没有成功:( 任何人都可以帮助我.如何在Android的Intent帮助下通过自己的应用程序的whatsapp发送文本消息和图像?
...全文
203 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38103285 2019-09-12
  • 打赏
  • 举报
回复
尝试使用以下解决方案, Intent sendIntent = new Intent("android.intent.action.SEND"); File f=new File("path to the file"); Uri uri = Uri.fromFile(f); sendIntent.setComponent(new ComponentName("com.whatsapp","com.whatsapp.ContactPicker")); sendIntent.setType("image"); sendIntent.putExtra(Intent.EXTRA_STREAM,uri); sendIntent.putExtra("jid", PhoneNumberUtils.stripSeparators("919xxxxxxxxx")+"@s.whatsapp.net"); sendIntent.putExtra(Intent.EXTRA_TEXT,"sample text you want to send along with the image"); startActivity(sendIntent); 关于寻找解决方案的过程的额外信息: 在对WhatsApp进行逆向工程后,我遇到了以下Android清单片段, 正常分享意图,使用“发送”,不允许您发送给特定联系人并需要联系人选择器. Conversation类会选择特定联系人并使用“SEND_TO”操作,但它使用sms正文并且无法占用图像和其他附件. <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:name="com.whatsapp.Conversation" android:theme="@style/Theme.App.CondensedActionBar" android:windowSoftInputMode="stateUnchanged"> <intent-filter> <action android:name="android.intent.action.SENDTO"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="sms"/> <data android:scheme="smsto"/> </intent-filter> </activity> 进一步挖掘,我遇到了这个, <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:name="com.whatsapp.ContactPicker" android:theme="@style/Theme.App.NoActionBar"> <intent-filter> <action android:name="android.intent.action.PICK"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="com.whatsapp"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.SEND"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="audio/*"/> <data android:mimeType="video/*"/> <data android:mimeType="image/*"/> <data android:mimeType="text/plain"/> <data android:mimeType="text/x-vcard"/> <data android:mimeType="application/pdf"/> <data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document"/> <data android:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/> <data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.presentation"/> <data android:mimeType="application/msword"/> <data android:mimeType="application/vnd.ms-excel"/> <data android:mimeType="application/vnd.ms-powerpoint"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.SEND_MULTIPLE"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="audio/*"/> <data android:mimeType="video/*"/> <data android:mimeType="image/*"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:host="send" android:scheme="whatsapp"/> </intent-filter> <meta-data android:name="android.service.chooser.chooser_target_service" android:value=".ContactChooserTargetService"/> </activity> 最后使用针对ContactPicker和Conversation类的反编译器,发现电话号码的额外键值为“jid”.

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧