I'm working on an app in Android that needs to open a WhatsApp conversation with a previously chosen sticker.
Maybe is there a way to do it like when a picture is sent, like this:
Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("image/*");
sendIntent.putExtra("jid", numero + "#s.whatsapp.net");
sendIntent.putExtra(Intent.EXTRA_TEXT, message);
sendIntent.putExtra(Intent.EXTRA_STREAM, filepath);
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
For my application, I would like to give share option.
For this, I have edit text to give phone number and a share button. If user gives a valid number and clicks share button, list of all available message sending application should list. If user selects an application from the list then a message with the application link should send his phone using the selected application.
How can I implement this? Please help.
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "message link");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Chooser title text"));
try this
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,"your application link"));
startActivity(Intent.createChooser(sharingIntent,"Share using"));
Try Below code,This is exactly that you want ,
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, Your_EditText_object.getText().toString());
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Your Title"));
Try this:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
References link:
https://developer.android.com/training/sharing/send.html
public static void callShare(Context theCtx, String theImagePath, String theText)
{
// Pass the message and Image path that you want to share
File myImageFile = new File(theImagePath);
String shareBody = theText; //"Here is the share content body " ;
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
if (myImageFile.exists()) {
// email address is required to be filled.
sharingIntent.setType("image/jpeg");
// "file://" and .getAbsolutePath is very important for Extra_Stream.
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + myImageFile.getAbsolutePath()));
} else if (!theText.isEmpty()) {
sharingIntent.setType("text/*");
}
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, ""); //"Subject here"
sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
sharingIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
theCtx.startActivity(Intent.createChooser(sharingIntent, "Share via"));
}
I have this code to send message via whatsapp
Uri uri = Uri.parse("smsto:" + PhoneNumber);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO, uri);
sendIntent.setPackage("com.whatsapp");
sendIntent.putExtra("sms_body", "Some text");
startActivity(sendIntent);
but when whatsapp is started it filled with the phone number but not with the text provided (also i've tried with Intent.EXTRA_TEXT)
I want to send message to specific Whatsapp contact. I have done following code but it only opens chatbox with specific contact but does not sent message.
//send message
String number="97*******";
Uri uri = Uri.parse("smsto:" + number);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO, uri);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Hi this is demo");
sendIntent.setPackage("com.whatsapp");
startActivity(Intent.createChooser(sendIntent, ""));
When I add
sendIntent.setType("text/plain");
it gives alert "No Application to perform this action".
Please tell how to resolve this. Thanks in advance.
I want to send an sms message and this code snippet works:
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "Check out this Punchit app!
https://market.android.com/details?id=com.punchit");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
Now I want to preset the phone number and tried both of the following:
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("tel:9999999999" ));
and
sendIntent.putExtra(android.content.Intent.EXTRA_PHONE_NUMBER, "9999999999");
Neither of these two statements work, so what is the correct syntax for presetting a phone number?
test as follows:
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "Hello1");
sendIntent.putExtra("address", "12345");
sendIntent.setType("vnd.android-dir/mms-sms")