My requirement is that I have to open directly (without app chooser) messaging default android screen from my application with to,body and vcf attachment. I am using below two methods(Approach).
But in first approach, attachment is coming but multiple app chooser screen comes first then I have to choose Messaging app.
In second approach, default messaging app is opening but attachment (.vcf) file is not coming. Please advice. Below is the code.
Approach 1:
public static void sendMMS(Context ctx,String firstname,String send_to,String body,String vcard)
{
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/x-vcard");
sendIntent.putExtra("address", send_to);
sendIntent.putExtra("sms_body", body);
File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),firstname+".vcf");
sendIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(file1));
((Activity) ctx).startActivity(sendIntent);
}
Approach 2:
private void sendMMS()
{
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.addCategory(Intent.CATEGORY_DEFAULT);
smsIntent.setType("vnd.android-dir/mms-sms");
File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"file.vcf");
smsIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(file1));
smsIntent.setData(Uri.parse("sms:" + "XXXXXXXXXXX"));
startActivity(smsIntent);
}
I got the solution finally as below. The main issue was that 1. Add ClassName in Intent and
2. Use file path starting from file:// and put it into Uri.parse()
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("sms_body", body);
sendIntent.putExtra("address", send_to);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Test.vcf"));
sendIntent.setType("text/x-vcard");
startActivity(sendIntent);
Related
I have a problem, I'm triying to send a mp3 file to gmail.
My code works good so far for whatsapp, hotmail, bluetooth... but it doesn't work with gmail
This is my code:
File sdCard = Environment.getExternalStorageDirectory();
String path = sdCard.getAbsolutePath() + "/" +"miApp"+"/tono.mp3";
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("audio/mp3");
intent.putExtra(Intent.EXTRA_SUBJECT, "Asunto");
intent.putExtra(Intent.EXTRA_TEXT, "Prueba");
intent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///" + path));
startActivity(intent);
I try with various types of mime but with the same results
"audio/x-mpeg-3"
"video/mpeg"
"video/x-mpeg"
"audio/mpeg"
What's wrong?
This worked for me
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("audio/mp3");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/miApp/tono.mp3"));
startActivity(i);
I am trying to send a jpg image through MMS using an HTC device (2.3.5, HTC Desire HD-Sense), I am using the following snippet
File sendfilepath = new File("file://" + sendfile);
Uri urimms = Uri.fromFile(sendfilepath);
Intent sendIntent = new Intent("android.intent.action.SEND_MSG");
sendIntent.putExtra(Intent.EXTRA_STREAM, urimms);
sendIntent.setType("image/jpeg");
startActivity(sendIntent);
It opens the Messaging app but it does not attach the image. I do not know why? It shows a toast "Cannot load message"
Something like this should work:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mmsto:<number>");
intent.putExtra("address", <number>);
intent.putExtra(Intent.EXTRA_STREAM, urimms);
intent.setType("image/jpeg");
startActivity(intent);
Otherwise these links look to be a little outdated but you should be able to translate everything pretty well:
Android MMS Intent with with Image and body text
http://androidforums.com/application-development/25988-send-image-action_send.html
try this
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/image_4.png"));
sendIntent.setType("image/png");
startActivity(sendIntent);;
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.
I have a custom file type (MIME_TYPE), basically xml, that I'd like to enable users to send to each other. Implementing the email send feature with the xml file as an attachment was straight forward but I'm kinda stuck on the SMS/MMS send feature. Anyone have any guidance?
final Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mms://"));
intent.setType("text/plain");
intent.putExtra("address", "2125551212");
String url = "content://myFile.txt";
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
intent.putExtra("sms_body", "some text goes here");
startActivityForResult(Intent.createChooser(intent, "mms-sms:"), SENT_TEXT);
the intent.putExtra(Intent.EXTRA_STREAM... doesn't seem to work, I get an error message:
"UNABLE TO ATTACH. FILE NOT SUPPORTED"
try this its worked with me for Send Photo.
use
Uri.fromFile
instead of
Uri.parse
File f=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/DCIM/Camera/"+img_name);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("", "");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
sendIntent.setType("image/png");
startActivity(sendIntent);
Im using the following code to send audio-files through email, dropbox +++..
This is not giving me the option to send the same file through MMS..
Anyone know how to attach it to a MMS and let the user send if he/she wants?
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/3gpp");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + aFile));
startActivity(Intent.createChooser(share, "Send file"));
you can used this code..
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("address", "9999999999");
sendIntent.putExtra("sms_body", "if you are sending text");
final File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"Downloadtest.3gp");
Uri uri = Uri.fromFile(file1);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("video/3gp");
startActivity(Intent.createChooser(sendIntent, "Send file"));
you have to used your appropriate set type .if audio then audio/*,image then image/png
This code work my samsung nexus,ace 5830 but not working htc amaze.If any one found any solution then please give snippet.