I'm trying to send an multimedia message(with an image) through an intent.How should I build the intent?
I've tried the code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/aaa.png")));
I can select mms app(Textra) from chooser dialog to send the image. But the chooser dialog lists other apps(such as Google Keep).
Then I tried this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
Only mms apps appears now.But I don't know how to attach my image.
Is there any solution for that?
try this may help,
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
intent.putExtra("sms_body", "write some text here");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/whatever.png")));
intent.setType("image/*");
startActivity(intent);
Try this way,hope this will help you to solve your problem.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "some text");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/aaa.png")));
intent.setType("image/png");
startActivity(intent);
Related
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 need to find all applications (among installed ones) that can open SMS. I have already found Gallery applications through the following method:
PackageManager pm = getPackageManager();
Intent newIntent = new Intent(Intent.ACTION_VIEW);
newIntent.setType("image/*");
allApps = pm.queryIntentActivities(newIntent, PackageManager.MATCH_DEFAULT_ONLY);
It gives me the list of all apps that can open images. Is there any similar way by which I can find all apps that can open SMS Messages?
You need to set set type as vnd.android-dir/mms-sms
Try this code :
Uri uri = Uri.parse("smsto:123456789");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body", "SMS text");
OR
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra("sms_body", "SMS text");
intent.putExtra("address", "123456789");
intent.setType("vnd.android-dir/mms-sms");
Hop it will help you :)
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);
Try this?
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_VIEW);
sendIntent.putExtra(Intent.EXTRA_TEXT,"Your Text");
sendIntent.setData(Uri.parse("sms:"));
startActivity(sendIntent);
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"));
I am trying to send an image via an MMS using the following code
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "Hi there");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/png");
It opens the Messaging apps and attach the message but it did not write the "sms_body" which is in my case "Hi there". Why?
try this:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
intent.putExtra("subject", "subject");
intent.putExtra("sms_body", "Hi there");
intent.putExtra("address", "Phonenumber");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
intent.setType("image/png");
startActivity(intent);
What seems to be working well is I just added EXTRA_TEXT (a solution which #yasserbn provided in a comment):
intent.putExtra(intent.EXTRA_TEXT, default_message);
in addition to:
intent.putExtra("sms_body", default_message);
And it seems to work whether it gets converted to multimedia message or sent as regular SMS.
How can implement an intent for sharing some text in a dialog like this ?
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath));
try
{
startActivity(Intent.createChooser(intent, "Sending File..."));
}
There u are:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, YOUR_TEXT_TO_SEND);
startActivity(Intent.createChooser(intent, "Share with"));
You can also use my library Android Intents. See demo app for details