I am using Android Studio. I have been trying to send picture using sms (or mms), but the code prompts me to launch and setup Microsoft outlook, and does not launch the SMS app. Any clue how I should I do it ?
this is the code I use:
` void sendPictureSMStoContact(String number) {
// First, I get the Uri of the picture
// Get the resource ID of the image in the drawable folder
int drawableId = R.drawable.brazil;
// Get the Resources object for your app's package
Resources resources = getResources();
// Get the URI of the image using the resource ID
Uri imageUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE +
"://" + resources.getResourcePackageName(drawableId)
+ '/' + resources.getResourceTypeName(drawableId)
+ '/' + resources.getResourceEntryName(drawableId));
// Second, I define an intent to handle the process
final Intent intent = new Intent(Intent.ACTION_SEND); // I also tried using ACTION_SENDTO
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(Uri.parse("sms:" + number)); // number is passed to the function
intent.setType("image/jpg");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent, "Share image using"));
}`
Also, in the manifest, I added permissions:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_MMS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />