Share audio file (.mp3) via Facebook, email, and SMS/MMS

后端 未结 7 2488
星月不相逢
星月不相逢 2020-12-18 11:10

I have an audio file (.mp3) and some information related to it. I want to share with Facebook, E-mail, SMS/MMS, etc..

What I have done is: when user clicks on the sh

相关标签:
7条回答
  • 2020-12-18 11:36

    You are try this.

     final Intent sendIntent  = new Intent(Intent.ACTION_SEND);
                sendIntent.putExtra("sms_body", "bod of sms");
                sendIntent.setType("*/*");
                sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
                final File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"test.amr");
                Uri uri = Uri.fromFile(file1);
                Log.e("Path", "" + uri);
                sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
                startActivity(Intent.createChooser(sendIntent, ""));
    
    0 讨论(0)
  • 2020-12-18 11:37
    File f=new File("full audio path");
    Uri uri = Uri.parse("file://"+f.getAbsolutePath());
    Intent share = new Intent(Intent.ACTION_SEND);
    share.putExtra(Intent.EXTRA_STREAM, uri);
    share.setType("audio/*");
    share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    context.startActivity(Intent.createChooser(share, "Share audio File"));
    
    0 讨论(0)
  • 2020-12-18 11:38

    You are trying to share an mp3 over services that don't support it.

    • Facebook supports text, pictures and videos.
    • SMS is plain text (and only very short plain text)
    • MMS does support audio, but (as far as I can tell from observation (i.e. without reading the spec)) only very low bit rate audio in some format that usually comes in a file with a .3g extension

    The apps do not show up in the list of supported apps for mp3 because they are not supported.

    0 讨论(0)
  • 2020-12-18 11:41

    There is no option for Facebook, but you can share email and MMS with Bluetooth. Here is my code. Take a look if it helps you:

    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("audio/*");
    share.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///"+mypath));
    startActivity(Intent.createChooser(share, "Share Sound File"));
    break;
    

    Here my path is the path of the sound file on the SD card.

    0 讨论(0)
  • 2020-12-18 11:42

    Use following code its working for me to share audio via intent.

    String path = Environment.getExternalStorageDirectory()
                    .getAbsolutePath() + "/abc.mp3";
    
    
            Intent share = new Intent(Intent.ACTION_SEND);
            share.setType("audio/*");
            share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + path));
            startActivity(Intent.createChooser(share, "Share Sound File"));
    
    0 讨论(0)
  • 2020-12-18 11:43
    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
            sharingIntent.setType("audio/*");
            sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,
                    Uri.fromFile(new File("filepath")));            
            startActivity(Intent.createChooser(sharingIntent,"Share using"));
    
    0 讨论(0)
提交回复
热议问题