Attached audio file as a mms in android

2019-07-07 10:36发布

问题:

I am develop one app that require record the voice.and that voice can be automatically attached to the mms.

i am useing this code

Intent sendIntent = new Intent(Intent.ACTION_SEND);  
                sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
                sendIntent.putExtra("address", "9999999999");
                sendIntent.putExtra("sms_body", "if you are sending text");   
                final File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"connection.amr");
                Uri uri = Uri.fromFile(file1);
                Log.e("Path", "" + uri);
                sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
                sendIntent.setType("*/*");
                startActivity(sendIntent);

all of the going fine but file can't attached automatically.any idea about this??

When user click on send button that time automatically attached that file in particular number with subject and sms_body part that it.

My file Extension is .3gp

This code is perfect work in Samsung ace 5830i and Samsung Galaxy nexus but not work in Htc desire c,Htc one.

I am tested this setType.but not positive response.

  sendIntent.setType("video/3gp");
  sendIntent.setType("audio/*");
  sendIntent.setType("*/*");
  sendIntent.setType("audio/mp3");

If automatic attachement is possible or not?

回答1:

Try this:

Intent sendIntent = new Intent(Intent.ACTION_SEND); 
sendIntent.putExtra("text-body", "if you are sending text");    
sendIntent.putExtra("num", "number");

sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("ur file path"));
sendIntent.setType("audio/3gp");