Here i am stuck from few days, i am trying to send sms(that predefined set from my app ) with selected contact to whats app, with the help of stackoverflow i found two method to send sms to whatsapp
.
1st method: one method is forward sms to whatsapp
well, but not with selected contact, contact can be select from whatsapp
but i not want that. I want contact also should be select from my app.now
2nd method: second method is opposite to first. This method send selected contact to whatsapp
for sms but not with (predefined sms).
My problem is that i want both things should be passed to whatsapp
from my app sms+Contact.When i try merge both method gives error. Please Help me
here is my code for 1st method and 2nd method.
//1st method: for forward sms to whatsapp
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = "YOUR TEXT HERE";
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(waIntent);
//2nd method: send sms with selected contact but not with predefined sms
void openWhatsappContact(String number) {
Uri uri = Uri.parse("smsto:" + number);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.setPackage("com.whatsapp");
startActivity(i);
//here i am trying to send both SMS and contact from my Android app but not working and get error.
Uri uri = Uri.parse("smsto:" + "065214585756");
Intent sendIntent = new Intent(Intent.ACTION_SENDTO, uri);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Hai Good Morning");
sendIntent.putExtra("chat",true);
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
Please any one help me.How i can do it.