I am working on a project where I need to send MMS from my android app. Below is the code which I tried but it is not working. Please advise.
Intent mmsIntent = new Intent(Intent.ACTION_SENDTO);
mmsIntent.addCategory(Intent.CATEGORY_DEFAULT);
mmsIntent.setType("vnd.android-dir/mms-sms");
mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));//Uri.parse(url));
mmsIntent.setData(Uri.parse("sms:" + "89565656"));
startActivity(mmsIntent);
check this:
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra("address","9876543211");
i.putExtra("sms_body","hello..");
i.putExtra(Intent.EXTRA_STREAM,Uri);
i.setType("image/png");
startActivity(i);
Here Uri is:
Uri uri = Uri.parse("content://media/external/images/media/1");
or
Uri uri = Uri.parse("file://mnt/sdcard/test.jpg");
or
Uri uri = Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/test.jpg");
For me below code is working perfect.....
Intent smsIntent = new Intent(android.content.Intent.ACTION_SEND);
smsIntent.putExtra("sms_body", mContext.getString(R.string.app_name));
smsIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + imagePath));
smsIntent.setType("image/png");
mContext.startActivity(smsIntent);
Related
I am trying to launch whatsapp app from my app and passing some text to a particular number. Whatsapp App is launching and but text is not able to pass.
String smsNumber = "98*******3";
Uri uri = Uri.parse("smsto:" + smsNumber);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.putExtra(Intent.EXTRA_TEXT, textWithClickableLink);
i.setPackage("com.whatsapp");
mContext.startActivity(i);
Is there anything missing in my code?
Please help me on this.
Thanks in advance!
Try this one:
Uri uri = Uri.parse("smsto:" + mobileno);
Intent whatsappIntent = new Intent(Intent.ACTION_SENDTO, uri);
whatsappIntent.setPackage("com.whatsapp");
String str = "https://play.google.com/store/apps/details?id=com.example.activity&hl=en";
whatsappIntent.putExtra("sms_body", str);
try {
activity.startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
// Whatsapp have not been installed
}
you can try this method, it should work. I have tested
private void shareWhatsApp() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "text to share");
//if you have any images to share sue this, uri is the uri of image
//shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
//shareIntent.setType("image/*"); for image sharing
shareIntent.setType("text/plain");
shareIntent.setPackage("com.whatsapp");
startActivity(shareIntent);
}
This will launch WhatsApp application and you have to manually select the contacts and send. since they dont provide any SDK we cant send automatically.
I tried this code. It makes my app to open list of all app by which I can send messages. After selecting any app now I am able to send the message that I am attaching with intent.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "From Stockal App");
intent.putExtra(Intent.EXTRA_TEXT, text);
mContext.startActivity(intent);
Thank you all for your response.
I'm using this code to share content ( Image from URL and text ). but this is not working properly. I'm getting no error, but it's not sharing (I'm trying to share in WhatsApp and GoogleDrive).
Uri imageUri = Uri.parse("http://2805messa.8.2.f.unblog.fr/files/2008/03/elmahdia.jpg");
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, post.getPost_text());
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
intent.setType("image/jpeg");
v.getContext().startActivity(intent);
I've already seen the other related posts, but I couldn't find an answer to my question.
Add the flag : FLAG_GRANT_READ_URI_PERMISSION. Also check for internet permissions.
Modified code:
Uri imageUri = Uri.parse(path);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, post.getPost_text());
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
intent.setType("image/jpeg");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
v.getContext().startActivity(intent);
i want direct sent message to phone number with viber , this code not work any one can help
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.addCategory(Intent.CATEGORY_DEFAULT);
smsIntent.setPackage("com.viber.voip");
smsIntent.setData(Uri.parse("sms:+1001002003"));
smsIntent.putExtra("address", "+1001002003");
smsIntent.putExtra("sms_body", "body text");
startActivity(smsIntent);
You can use this method
public void sendToViber(String messageBody, String viberContact) {
Uri uri = Uri.parse("smsto:" + viberContact);
Intent viberIntent = new Intent(Intent.ACTION_SENDTO, uri);
viberIntent.setPackage("com.viber.voip");
startActivity(Intent.createChooser(viberIntent, "Share"));
}
I have made an android app ,I want to share a drawable to twitter,Currently I have done this way for text,But can any buddy tell me how to attach image to intent to share via twitter ,Thank you in advance,My code is as below:
public void shareTwitterIntent() {
String tweetUrl = "https://twitter.com/intent/tweet?text=3SManiquines";
Uri uri = Uri.parse(tweetUrl);
startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
Try this (from How to attach a Bitmap when launching ACTION_SEND intent -- perhaps a duplicate?):
String pathofBmp = Images.Media.insertImage(getContentResolver(), bitmap,"title", null);
Uri bmpUri = Uri.parse(pathofBmp);
final Intent emailIntent1 = new Intent( android.content.Intent.ACTION_SEND);
emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent1.putExtra(Intent.EXTRA_STREAM, bmpUri);
emailIntent1.setType("image/png");
I have my images in drawable folder and I am getting that images in gridview.Also I am showing the perticular image on selection fullscreen.Now I want to send MMS with image attachment.
Here is my code to show the image. And to send MMS.how to get Uri to put to intent or how to send the image attachment.
imageView.setImageResource(imageAdapter.mThumbIds[position]);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "Hii");
sendIntent.setType("image/png");
startActivity(sendIntent);
Use the following code to send the mms.. Hope this wil help you.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "Hi how are you");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/file.gif")));
intent.setType("image/gif");
startActivity(Intent.createChooser(intent,"Send"));
Uri uri = Uri.parse("android.resource://your.package.here/drawable/image_name");
EDIT:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "Hi how are you");
Uri uri = Uri.parse("android.resource:// com.example.stack/drawable/ic_launcher.png");
intent.putExtra(Intent.EXTRA_STREAM,uri );
intent.setType("image/png");
startActivity(Intent.createChooser(intent,"Send"));