Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
563 views
in Technique[技术] by (71.8m points)

sms - Android: How to send message programmatically by using WhatsApp, WeChat?

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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();
    }
}

Note : change *PACKAGE NAME OF THE APPLICATION as per your requirement like

Example : USE

//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");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...