Intent.ACTION_SEND Whatsapp

后端 未结 4 1742
野趣味
野趣味 2020-12-21 02:04

Im trying to share a mp3 file through whatsapp. It works perfectly with other apps like gmail, but it dosent works on whatsapp. Can anyone help me? Do I need to add some put

相关标签:
4条回答
  • 2020-12-21 02:34

    WhatsApp also accepts OGG format:

    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("audio/ogg");
    shareIntent.putExtra(Intent.EXTRA_STREAM, getSoundUri());
    startActivity(shareIntent);
    
    0 讨论(0)
  • 2020-12-21 02:39

    Try changing the MIME type to "audio/mpeg3" so that the second line reads

    share.setType("audio/mpeg3")
    
    0 讨论(0)
  • 2020-12-21 02:48

    You have to Include this in you code:

    sendIntent.setPackage("com.whatsapp");
    
    0 讨论(0)
  • 2020-12-21 02:51

    You should copy your audio file to sdcard, and share it as file, not as android resource, like this:

    final Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("audio/mp3");
    shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file://"+path+filename));
    startActivity(Intent.createChooser(shareIntent, getString(R.string.share_sound)));
    

    Now it should work through whatsapp.

    0 讨论(0)
提交回复
热议问题