Android:如何使用WhatsApp,微信以编程方式发送消息? [英] Android: How to send message programmatically by using WhatsApp, WeChat?

查看:359
本文介绍了Android:如何使用WhatsApp,微信以编程方式发送消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过使用 WhatsApp 微信在android应用程序中使用消息传递?

How to use messaging in android application by using WhatsApp and WeChat?

实际上要求是使用WhatsApp和微信(免费短信)发送短信.

Actually requirement is to send sms using WhatsApp and WeChat (Free sms).

推荐答案

我得到了解决方案..在这里,我发布答案,以便对其他有相同疑问的人提供帮助.

I got the Solution.. Here I am posting the answer so that it may help other people who may have same doubt..

通过任何应用程序共享...

For Share through any application...

public void sendAppMsg(View view) {

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    String text = " message you want to share..";
    // change with required  application package  

    intent.setPackage("PACKAGE NAME OF THE APPLICATION");
    if (intent != null) {
        intent.putExtra(Intent.EXTRA_TEXT, text);//
        startActivity(Intent.createChooser(intent, text));
    } else {

        Toast.makeText(this, "App not found", Toast.LENGTH_SHORT)
                .show();
    }
}

注意:根据您的要求

示例:使用

//Whatsapp
    intent.setPackage("com.whatsapp");`

//Linkedin
    intent.setPackage("com.linkedin.android");

//Twitter    
    intent.setPackage("com.twitter.android");

//Facebook
    intent.setPackage("com.facebook.katana");

//GooglePlus
    intent.setPackage("com.google.android.apps.plus");

这篇关于Android:如何使用WhatsApp,微信以编程方式发送消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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