Android - 使用彩信发送音频文件

标签 android audio android-intent mms

我使用以下代码通过电子邮件、Dropbox+++ 发送音频文件.. 这不是给我通过彩信发送相同文件的选项。 任何人都知道如何将它附加到 MMS 并让用户在他/她想要时发送?

        Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("audio/3gpp");
        share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + aFile));
        startActivity(Intent.createChooser(share, "Send file"));

最佳答案

你可以使用这个代码..

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(),"Downloadtest.3gp");
            Uri uri = Uri.fromFile(file1);

            sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
            sendIntent.setType("video/3gp");
            startActivity(Intent.createChooser(sendIntent, "Send file"));

您必须使用合适的设置类型。如果音频然后是 audio/*,图像然后是 image/png

此代码适用于我的三星 nexus、ace 5830 但不适用于 htc amaze。如果有人找到任何解决方案,请提供代码段。

关于Android - 使用彩信发送音频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5213017/

相关文章:

android - 使用 Arduino 固件在 ESP8266 上附加中断

android - 如何在 rxjava 和改造中每小时重试请求 5 次

html - 如果我在 AngularJS 中使用数组中的链接,为什么音频不播放?

matlab - FFT的功率谱密度

android - 切换到前置摄像头和后置摄像头 Android SurfaceView

javascript - 网络音频 Api 和 Javascript : Get the correct picks from microphone

android - onCreate() 中的 extra 为空值

android - 使用 Intent 通过按钮将微调器对象传递给新 Activity

通配符上的 Android 主机 Intent 过滤器

android - 运行时权限 : shouldshowrequestpermissionrationale always returns false