简体   繁体   中英

SmsManager, send attachment in sms

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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM