问题
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.
回答1:
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" />
来源:https://stackoverflow.com/questions/24262198/smsmanager-send-attachment-in-sms