How can i send an MMS in android ?
My code using UI as follows :
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("address", "5556");
intent.putExtra("sms_body", "Gudmng !!");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new File("/sdcard/sky.png"));
intent.putExtra(Intent.EXTRA_STREAM, uri); // imageUri set
intent.setType("image/*")
startActivity(intent);
But still the exception in sending MMS
ERROR/HierarchicalStateMachine(68): TetherMaster - unhandledMessage: msg.what=3
Any Help?
I'm not sure what the problem with your code is, but I have used this and it works:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpg");
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("sms_body", "hello");
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivityForResult(sendIntent, 0);
Maybe you can incorporate this and change it according to your needs.
If you have to send mms with any image then this code.
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);
Try this :
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Chitza Share");
// shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, data);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, Activity_Home.sharefileUriList);
// shareIntent.putExtra(Intent.EXTRA_STREAM, (Serializable) sharefileUriList);//pass uri here
final List<ResolveInfo> activities = activity.getPackageManager().queryIntentActivities(shareIntent, 0);
List<DialogItem> appNames = new ArrayList<DialogItem>();
for (ResolveInfo info : activities) {
appNames.add(new DialogItem(info.loadLabel(activity.getPackageManager()).toString(),
info.loadIcon(activity.getPackageManager())));
}
Related
How send mms with attach in Android 4.0+? I try like:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/png");
sendIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse(outputFile.toURL().toString()));
startActivity(sendIntent);
It is work good in htc and samsung, but it is do not work in Nexus 5 (hangouts). I try like:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("address", phonesBuilder2.toString());
sendIntent.putExtra("sms_body", editTextTPMessage.getText());
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(makePicture()));
But file is not attach. I try very much ways, but all ways have problem.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "Hi how are you"); //Version dependent
intent.putExtra(Intent.EXTRA_TEXT, "Hi how are you"); //Version dependent
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/file.gif")));
intent.setType("image/gif");
startActivity(Intent.createChooser(intent,"Send"));
Here i am sharing images from my app to whatsapp.but this code is working here only for mylist1[i] and not for mylist2[i] and mylist3[i]. As in my activity file there are 15 images in every list. what to do?
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
Uri uri = Uri.parse("android.resource://com.example.drawcelebrities/"+mylist1[i]+mylist2[i]+mylist3[i]);
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share via"));
Take image array in mylist[] and use below code, then share image via whatsapp.
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+mylist[i]);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share via"));
If I'm not wrong then for that you should use android.content.Intent.ACTION_SEND_MULTIPLE..Refer this link it will help you..
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.putExtra(Intent.EXTRA_SUBJECT, "Here are some files.");
intent.setType("image/jpeg");
ArrayList<Uri> files = new ArrayList<Uri>();
for(String path : filesToSend /* List of the files you want to send */) {
File file = new File(path);
Uri uri = Uri.fromFile(file);
files.add(uri);
}
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
startActivity(intent);
This is my code
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.twitter.android", "com.twitter.android.PostActivity");
intent.putExtra(Intent.EXTRA_TEXT, message);
startActivity(intent);
can i attach picture programmatically?
EDIT
SOLUTION
1 more line additional
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.twitter.android", "com.twitter.android.PostActivity");
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.putExtra(Intent.EXTRA_STREAM, Uri);
startActivity(intent);
Try this.
Intent sharingIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
Uri screenshotUri = Uri.parse("file:///sdcard/image.jpg");
sharingIntent.setType("*/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
Try this Code it works perfectly..if you having twitter application installed in your mobile. otherwise use try..catch
var postrTwitter = Ti.Android.createIntent({
action : Ti.Android.ACTION_SEND,
packageName : "com.twitter.android",
className : "com.twitter.android.PostActivity",
flags : Ti.Android.FLAG_ACTIVITY_NEW_TASK,
type : "text/plain"
});
postrTwitter.setType("*/*");
postrTwitter.putExtra(Ti.Android.EXTRA_TEXT, "Text message ");
postrTwitter.putExtraUri(Ti.Android.EXTRA_STREAM, image_file.nativePath);
Ti.Android.currentActivity.startActivity(postrTwitter);
String message = "Text I want to share";
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(share,"Share on"));
right now it shows the default options like: Bluetooth, Email, Facebook, Gmail, LinkedIn, Messaging, Share Via Barcode.
or are these the installed apps?
what i want is to know, how i can remove few from this list. like i want to remove Share Via Barcode.
and add something else?
Thank You
Use below code to add a new Item to the Chooser Screen.
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);
Intent addIntent = ;//whatever you want
Intent chooser = new Intent(Intent.ACTION_CHOOSER);
chooser.putExtra(Intent.EXTRA_INTENT, share );
chooser.putExtra(Intent.EXTRA_TITLE, "title");
Intent[] intentArray = {addIntent };
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
startActivity(chooser);
But removing specific items is not possible. So you could resolve the intent using Packagemanager.resolveActivity and create your own custom list view
I used the following code to get a list of all eMail and SMS apps installed on the device:
Intent shareSMS = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", "12346556", null));
shareSMS.addCategory(Intent.CATEGORY_DEFAULT);
shareSMS.putExtra("sms_body", message);
Intent shareEmail = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "", null));
PackageManager pm = getPackageManager();
List<ResolveInfo> mailActivityList = pm.queryIntentActivities(shareEmail, PackageManager.MATCH_DEFAULT_ONLY);
List<Intent> mailIntents = new ArrayList<Intent>();
for (ResolveInfo resInfo : mailActivityList) {
Intent targetedOpenIntent = new Intent(android.content.Intent.ACTION_SENDTO, Uri.fromParts("mailto", "", null))
.setPackage(resInfo.activityInfo.packageName)
.putExtra(Intent.EXTRA_EMAIL, emails)
.putExtra(Intent.EXTRA_SUBJECT, subject)
.putExtra(Intent.EXTRA_TEXT, message);
mailIntents.add(targetedOpenIntent);
}
Intent chooser = new Intent(Intent.ACTION_CHOOSER);
chooser.putExtra(Intent.EXTRA_INTENT, shareSMS);
chooser.putExtra(Intent.EXTRA_TITLE, "Send request");
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, mailIntents.toArray(new Parcelable[] { }));
startActivity(chooser);
Adding Option to chooser
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);
Intent extraOptionToAdd = new Intent(this, ExtraOptionActivity.class);
extraOptionToAdd.putExtra(Intent.EXTRA_TEXT, "Text");
LabeledIntent labeledExtraOption = new LabeledIntent(extraOptionToAdd, getPackageName(), "Extra Option!", 0);
Intent chooser = Intent.createChooser(share, "Share Now!");
Intent[] intentArray = {labeledExtraOption};
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
startActivity(chooser);
I my application I have to attach an image from drawable folder to email client.
I have no idea how to do it.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
Uri path = Uri.parse("android.resource://your.package.name/" + R.drawable.sample_1);
intent.putExtra(Intent.EXTRA_STREAM, uri);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/png");