如何在Android的Intent帮助下通过Whatsapp从自己的应用程序发送文本消息和图像?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何在Android的Intent帮助下通过Whatsapp从自己的应用程序发送文本消息和图像?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3630字,纯文字阅读大概需要6分钟。
内容图文
我无法通过whatsapp发送短信和图片.要么,我能够
在没有任何消息的情况下启动该特定联系人聊天线程,或者我只能发送消息但不能打开该特定联系人聊天线程.
我关注了以下链接:
http://www.whatsapp.com/faq/en/android/28000012
Sending message through WhatsApp
Send Whatsapp message to specific contact
但没有成功:(
任何人都可以帮助我.
如何在Android的Intent帮助下通过自己的应用程序的whatsapp发送文本消息和图像?
解决方法:
尝试使用以下解决方案,
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”.
内容总结
以上是互联网集市为您收集整理的如何在Android的Intent帮助下通过Whatsapp从自己的应用程序发送文本消息和图像?全部内容,希望文章能够帮你解决如何在Android的Intent帮助下通过Whatsapp从自己的应用程序发送文本消息和图像?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。