Search code examples
androidandroid-intentmms

Don't want option to be given for sending mms`


I have a requirement in my application in which I have to send MMS on click of button. When I click on the button it prompts to choose using which application I want to complete the action either email or messaging. I want it to open by default with messaging. I searched a lot but couldn't get any answer. Below, I am posting my code:

public class MMSActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Button mms = (Button)findViewById(R.id.mms);
    mms.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            sendMMS();
        }
    });
}

public void sendMMS() {
    Intent in = new Intent(Intent.ACTION_SEND);
    in.putExtra("sms_body", "some text");
    in.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(Environment.getExternalStorageDirectory()
            .getAbsolutePath().toString()+"/diplomat/ALEXANDRA-1339242345022.jpg")));
    in.setType("image/jpeg");
    startActivity(in);
    Log.d("MMS", "SendMMS called");
}
}

I even tried with setting class as android.telephony.SmsMessage but it didn't worked.


Solution

  • I want it to open by default with messaging

    First, it is unclear what you think "messaging" is. I will assume that you mean the Android open source project (AOSP) MMS client.

    Second, many devices do not have this app. Device manufacturers are welcome to use whatever MMS client they wish, which may or may not be the AOSP client.

    Third, users are welcome to install and use their own SMS/MMS clients that they obtain from the Play Store or elsewhere. By saying that users should not have a choice in the matter, you are saying that you are more important than your users. Your users will tend to disagree.

    Please allow your users to use whatever MMS client they wish, and at least one that actually exists.