问题
I have made a program, in which I am sending some text to pre defined contact number, but now I also want to send voice message to that number please let me know how can I do this?
To send text SMS I am using below code:-
String phoneNumber = "XXXX9";
String message = editLocation.getText().toString();
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber, null, message, null, null);
Toast.makeText(getApplicationContext(),
"Message Sent!", Toast.LENGTH_LONG).show();
回答1:
Refer this link. In this link there is an explaination on how to send images via MMS. you can just replace the image file with the Audio File. you can find the code to send voice message in the Comments of the above link.
回答2:
Try something like this
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url)); // url would point to mp3 file
sendIntent.setType("audio/mp3");
来源:https://stackoverflow.com/questions/14036327/send-voice-message-to-another-contact-number