I am beginer in android. I use this code to automatically send MMS
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra("address","1234567890");
i.putExtra("sms_body","hai");
i.putExtra(Intent.EXTRA_STREAM,path);
i.setType("image/jpg");
startActivity(i);
but it shows application chooser and when we select messaging application ,the image is loaded with message, but it can't send automatically. we need user interaction for this. I would need to automatically choose message app and send MMS automatically without user interaction. Please help me. Thanks in advance
SmsManager API
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);
Built-in SMS application
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "default content");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
<uses-permission android:name="android.permission.SEND_SMS" />
Related
i already know the code how to send sms by typing the number and the message, but what i want to know is it possible to send message only without typing the contact number? Here’s my situation, im working at water district, I’m making app for reporting leak thru text, what i want to happen is, the reporter is only need to type the message then send, without inputting the number. We only have 1 hotline number, so I don’t think the reporter need to type the contact number everytime the reporter text us, he just need to type the message then click send only.
send sms without inputting contact number
Following code works without inputting the number again and again. The address attribute stores the number(hotline number) and When user clicks on report it default takes you to messaging app with number already stored and allow to write the text and go.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setType("vnd.android-dir/mms-sms/");
intent.putExtra("address", your_hotline_number);
intent.putExtra("sms_body", " ");
startActivity(intent);
Try this it's working for me:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", "12345", null)));
Keep the recipient number in a constant field as
public static final String recipientNo = "*********";
Then if you use implicit intent the add below code
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + recipientNo));
intent.putExtra("sms_body", message);
startActivity(intent);
or if you use SmsManager,
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
and add permission in AndroidManifest.xml
<uses-permission android:name="android.permission.SEND_SMS"/>
how to send a whatsapp message to a specific contact automatically?I have searched but it just opens the chat of that specific person but does not send the message automatically
Here is the code that am using:
private void openWhatsappContact(String number) {
Uri uri = Uri.parse("smsto:" + number);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.setPackage("com.whatsapp");
startActivity(Intent.createChooser(i, ""));
I'm not sure you can send the message automatically, but try this to specify the message you want to send:
i.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
Reference:
https://www.whatsapp.com/faq/en/android/28000012
There is no direct way to do this because whatsapp does not offer an SDK interface.
You might have some luck with writing some accessibility automations or if you have root may be some xposed module.
I'm develop an app use mms message of android.
Currently I can:
Send ssm message but not attached image by use following code:
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.addCategory(Intent.CATEGORY_DEFAULT);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("sms_body", message);
smsIntent.setData(Uri.parse("sms:" + phoneNumber));
((Activity) context).startActivityForResult(smsIntent, 0);
Send attach image via third party app:
Intent mmsIntent = new Intent(Intent.ACTION_SEND);
mmsIntent.putExtra("sms_body", "Please see the attached image");
mmsIntent.putExtra(Intent.EXTRA_STREAM, attached_Uri);
LogUtils.debug(TAG, "extension: " + extension);
mmsIntent.setType(extension);
((Activity) context).startActivityForResult(mmsIntent, 0);
My problems:
Can't attach image to default messaging app of android.
How can i detect if default messaging app of android device ( such as tablet ) not exist.
So, please guild me on this problem.
Thanks you so much.
Solution for 1st problem
Intent mmsIntent = new Intent(Intent.ACTION_SEND);
mmsIntent.putExtra("sms_body", "Please see the attached image");
mmsIntent.putExtra(Intent.EXTRA_STREAM, attached_Uri);
mmsIntent.setType("image/gif");
startActivity(Intent.createChooser(mmsIntent,"Send"));
Solution for 2nd problem
You don't have to worry about that, Playstore will.
If you are using sms feature you would have given permission. So your app will not be vissible in playstore for SMS featureless devices
EDIT:
To include the sender address add an additional EXTRA to the intent
mmsIntent.putExtra("address","number_here");
How do I add an "attachment" into my SmsManager object when I'm trying tro send an sms?
My current function for sending a normal sms is:
public void send() {
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(this.number, null, this.message, null, null);
}
I have looked a little bit at the sendDataMessage() but don't really understand it.. any help is appreciated.
Thanks.
EDIT
I don't want to use Intent for this. I have a List with Bitmap images that I want to send via an SMS/MMS. So I don't want to invoke the SMS app in my application. I want to send attachments "dynamically" depending on what's in my List.
SOLUTION
A friend of mine just posted me this link to a library: https://github.com/klinker41/android-smsmms
Message mMessage = new Message(textToSend, addressToSendTo);
mMessage.setImage(mBitmap); // not necessary for voice or sms messages
mMessage.setType(Message.TYPE_SMSMMS); // could also be Message.TYPE_VOICE
Haven't tried it yet, but it seems to be the real deal. Hope it's for good use for someone else too.
follow the code
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "default content");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
and add permission
<uses-permission android:name="android.permission.SEND_SMS" />
I am trying to send msg body and contacts from my app to other available sms apps like whatsapp, default sms app, skype etc. But it is working properly for only default app and for others it is either taking only msg body or only contacts...I have tried other Actions like SEND also..
Uri uri = Uri.parse("smsto:" + destination);
Intent intent = new Intent(Intent.ACTION_SENDTO,uri);
intent.putExtra(Intent.EXTRA_TEXT, editMessage.getText().toString());
startActivity(Intent.createChooser(intent, "Share with"));
Try this code:
data.setAction(Intent.ACTION_VIEW);
data.setData(Uri.parse("sms:(234) 567-8901"));
data.putExtra(Intent.EXTRA_TEXT, "Hello from "+getResources().getString(R.string.app_name));
It works for me.