gpt4 book ai didi

android - 如何在社交媒体(whatsapp,gmail等)上共享/发送音频文件,android studio

转载 作者:行者123 更新时间:2023-12-03 01:14:23 26 4
gpt4 key购买 nike

我想与社交媒体(如whatsapp,drive,gmail等)共享音频文件。
我尝试了这段代码,

  • 我单击whatsapp图标后得到按摩:
    “不支持文件格式”
  • 我单击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");

    最佳答案

    检查以下代码

    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找到了这个答案

    关于android - 如何在社交媒体(whatsapp,gmail等)上共享/发送音频文件,android studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62968040/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com