通过WhatsApp的发送邮件到意向 [英] Sending message through WhatsApp By intent

查看:240
本文介绍了通过WhatsApp的发送邮件到意向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何我可以从我的应用程序在WhatsApp的发送按摩特殊号码,我知道这code,分享按摩组或WhatsApp的联系人

How I can send massage from my app to Special number in whatsapp , I know this code to share massage to group or contact on whatsapp

Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = "Sorry For Interruption,I'm Just Trying Something";
waIntent.setPackage("com.whatsapp");

if (waIntent != null) {
    waIntent.putExtra(Intent.EXTRA_TEXT, text);//
    startActivity(Intent.createChooser(waIntent,"Share with"));

但我想送按摩,特殊号码,如966xxxxxxx我怎么能做到这一点?

but I want send massage to Special number like "966xxxxxxx" how I can do that ?

推荐答案

这是一个解决方案:

private void openWhatsApp(String id) {

Cursor c = getSherlockActivity().getContentResolver().query(ContactsContract.Data.CONTENT_URI,
        new String[] { ContactsContract.Contacts.Data._ID }, ContactsContract.Data.DATA1 + "=?",
        new String[] { id }, null);
c.moveToFirst();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("content://com.android.contacts/data/" + c.getString(0)));

startActivity(i);
c.close();
}

其中id是什么样的应用程序的URI像966123456789@s.whatsapp.net

Where id is what's app uri like 966123456789@s.whatsapp.net

这篇关于通过WhatsApp的发送邮件到意向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆