Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google's Messenger app not attach Image while send MMS

I'm unable to send MMS with image on Google's Messenger app. While some of the android device by default install this SMS app and for that when I send MMS using Intent than it's not working.

The problem is ToNumber and MMS content set but the image is not attach on this app.

Note: I already set the MMS APN setting on my devices,and i already check on multiple devices with same app like Samsung s4,Motorola G4 Plus.

This is my code currently I Used.

 String toNumbers = "comma seperated mobile numbers";   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)      {         String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(getActivity());           Intent sendIntent = new Intent(Intent.ACTION_SEND);         sendIntent.putExtra("address", toNumbers);         sendIntent.setPackage("com.android.mms");         //Uri uri = Uri.fromFile(new File(getContext().getExternalFilesDir(""), "image.png"));          File imagePath = new File(getFilesDir(), "images");         File newFile = new File(imagePath, "image.png");         Uri uri = getUriForFile(this, "packagename", newFile);          File file = new File(contentUri.getPath());         if (file.exists()) {             //Do something             Log.d("TAG","Exist");         }         sendIntent.putExtra(Intent.EXTRA_STREAM, uri);         sendIntent.setType("image/png");         sendIntent.putExtra("sms_body", getString(R.string.sms_body, HostName));         if (defaultSmsPackageName != null)         {             sendIntent.setPackage(defaultSmsPackageName);         }         startActivityForResult(sendIntent, Constants.SEND_SMS_REQUEST);       }     else      {         Intent smsIntent = new Intent(android.content.Intent.ACTION_VIEW);         smsIntent.putExtra("address", toNumbers);         smsIntent.setPackage("com.android.mms");         Uri uri = Uri.fromFile(new File(getContext().getExternalFilesDir(""), "image.png"));         smsIntent.putExtra(Intent.EXTRA_STREAM, uri);         smsIntent.setType("image/png");         smsIntent.putExtra("sms_body", getString(R.string.sms_body, HostName));         startActivityForResult(smsIntent, Constants.SEND_SMS_REQUEST);     } 

file_paths.xml

<paths xmlns:android="http://schemas.android.com/apk/res/android"> <files-path     name="files"     path="images/" />  </paths> 

manifeast.xml

<provider         android:name="android.support.v4.content.FileProvider"         android:authorities="packagename"         android:exported="false"         android:grantUriPermissions="true">         <meta-data             android:name="android.support.FILE_PROVIDER_PATHS"             android:resource="@xml/file_paths" />       </provider> 
like image 342
Abhishek Patel Avatar asked Aug 11 '16 05:08

Abhishek Patel


People also ask

Why can't I send MMS?

Check the Android phone's network connection if you can't send or receiving MMS messages. An active cellular data connection is required to use the MMS function. Open the phone's Settings and tap “Wireless and Network Settings.” Tap “Mobile Networks” to confirm it is enabled.

How do you send pictures through Facebook Messenger on Android?

Send a photo, video, sticker or voice message on MessengerOpen any conversation, then tap the following options at the bottom next to the text box. If you don't see these options, tap next to the text box first. Take and send new photos or videos. Send photos or videos.

Why won't my phone send or receive pictures?

If your smartphone refuses to send or receive picture messages, check that data connection is active and enabled on your device. If you're using Wi-Fi, temporarily disable Wi-Fi and use cellular data. You cannot send MMS over Wi-Fi, so you should make sure you have an active cellular/mobile data plan.

Why can't I receive MMS messages on my phone?

You can try to fix that by clearing the Messages app's app data. On your phone, go to Settings > Apps & notifications > Messages > Storage. Tap on the option that says Clear Storage followed by Clear Cache. Relaunch the Messages app and you should be able to use MMS.

Why is Facebook Messenger not sending pictures on Android?

If Facebook Messenger is still not sending pictures on Android, make sure that your time and date are properly set. Like with the majority of instant messengers, media and text messages go to a dedicated server and are later (in a matter of seconds) distributed to recipients.

How do I enable MMS on my Android phone?

On your phone, go to Settings > Apps & notifications > Messages > Storage. Tap on the option that says Clear Storage followed by Clear Cache. Relaunch the Messages app and you should be able to use MMS.

How do I auto download MMS messages on Android?

Make Sure Auto-download MMS is Turned on 1 Launch the Messages app on your phone. 2 Tap on the three-dots at the top-right corner of your screen and choose Settings. 3 Enable the Auto-retrieve option under the MMS section.


1 Answers

file_paths.xml and manifest.xml are the same as in your code.

Create content uri:

File imagePath = new File(getFilesDir(), "images"); File newFile = new File(imagePath, "image.png"); Uri contentUri = FileProvider.getUriForFile(this, "packagename", newFile); 

Check content uri:

ImageView imageView = (ImageView) findViewById(R.id.imageview); //Your image should be displayed imageView.setImageURI(contentUri); 

Create intent:

Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "Text to send"); sendIntent.putExtra(Intent.EXTRA_STREAM, contentUri); sendIntent.setType("image/png"); 

Solution tested on:

a) Galaxy S4, Android 5.0, Messenger ver: 1.9.036

b) Emulator: Nexus 5, Android 6.0, Messaging ver: 1.0.001

like image 107
wdeb Avatar answered Sep 24 '22 02:09

wdeb