How to send image via MMS in Android?

后端 未结 4 1853
深忆病人
深忆病人 2020-11-22 04:36

I am working on a multimedia application. I am capturing one image through the camera and want to send that image with a text to some other number. But I am not getting how

4条回答
  •  心在旅途
    2020-11-22 05:19

    If you have to send MMS with any Image using Intent then use this code.

    Intent sendIntent = new Intent(Intent.ACTION_SEND); 
    sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
    sendIntent.putExtra("sms_body", "some text"); 
    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/image_4.png"));
    sendIntent.setType("image/png");
    startActivity(sendIntent);;
    

    OR

    If you have to send MMS with Audio or Video file using Intent then use this.

    Intent sendIntent = new Intent(Intent.ACTION_SEND); 
    sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
    sendIntent.putExtra("address", "1213123123");
    sendIntent.putExtra("sms_body", "if you are sending text");   
    final File file1 = new File(mFileName);
    if(file1.exists()){
      System.out.println("file is exist");
    }
    Uri uri = Uri.fromFile(file1);
    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
    sendIntent.setType("video/*");
    startActivity(sendIntent);
    

    let me know if this help you.

提交回复
热议问题