【问题标题】:how to share / send an audio file on social media(whatsapp,gmail, etc), android studio如何在社交媒体(whatsapp、gmail 等)、android studio 上共享/发送音频文件
【发布时间】:2020-11-08 02:10:12
【问题描述】:

我想与 whatsapp、drive、gmail 等社交媒体分享音频文件。 我试过这段代码,

  1. 点击whatsapp图标后,我得到了按摩: “不支持该文件格式”
  2. 点击 gmail 图标后,我得到了按摩: “无法附加文件”
    //sharePath: my audio path file
    String sharePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + songNameAndDateArray.get(newI).getSongName().toString() + "FinalSongRec" + "File" + "AudioRecording.3gp";
    File f = new File(sharePath);
    Uri uri = Uri.parse(f.getAbsolutePath());
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("audio/*");
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    startActivity(Intent.createChooser(shareIntent,"share audio");

【问题讨论】:

    标签: android file audio share send


    【解决方案1】:

    检查以下代码

    String sharePath = Environment.getExternalStorageDirectory().getPath()
                + "/Soundboard/Ringtones/custom_ringtone.ogg";
        Uri uri = Uri.parse(sharePath);
        Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("audio/*");
        share.putExtra(Intent.EXTRA_STREAM, uri);
        startActivity(Intent.createChooser(share, "Share Sound File"));
    

    我从以下链接Sharing audio file找到了这个答案

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-07
      • 2019-03-18
      • 1970-01-01
      • 2012-06-05
      • 2019-03-15
      • 2019-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多