Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
181 views
in Technique[技术] by (71.8m points)

How to share the Particular SQLITE audio file to Gmail in android?

I am working audio recording app, in which the audio is recorded and stored inside the app and that path is stored in SQLITE.

I need that audio file to be shared in whatsapp/gmail or saved in internal directory of mobile.

I try to share them using the Intent but in whatsapp it showed unsupported format.

I tried this code

    private void Shareoption(List<RecordData> uploadlist)
{
    RecordData reco2 = uploadlist.get(0);
    String id3 = reco2.getId();
    final RecordData recordData = DBcreatedata.getData(id3);
    final File f;
    locname =   recordData.getRecordDataTitle();
    f = new File(recordData.getRecordData());

    Uri uri = Uri.parse(f.getAbsolutePath() );
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("audio/*");
    share.putExtra(Intent.EXTRA_STREAM, uri.toString());
    startActivity(Intent.createChooser(share, "Share Sound File"));

And I also searched about this and I came to know that first the audio file must be stored in internal directory before sharing. So I tried input output stream method, it did not work.

Can any one help me to share this audio file ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

By using this I think your problem will be solved

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri shareFileUri= Uri.parse(string);
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
sharingIntent.setType("*/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, shareFileUri);
sharingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(sharingIntent, "Share Sound File"));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...