I have this code to send an SMS message with an attachment that is coming from the raw/ folder:
String uri= "mmsto:";
String uri2 = "android.resource://[my_package]/";
Intent mmsIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
mmsIntent.setType("Audio/basic");
mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(uri2+R.raw.sound));
mmsIntent.putExtra("compose_mode", true);
startActivity(mmsIntent);
This code is esecuted when I press a button button1. However, It opens an SMS application but with NO attachment.
Am I doing this wrong ?
Open the attachment as asset will do the work.
P.S: To be clear, move the file to asset folder 🙂
Something like here: