Search code examples
javaandroidsharefacebook-messenger

Can't share audio in Messenger if the name has a space


I'm writing an Android voice recorder app. I have a button where I click to share my audio file. But... I can't share it in Messenger if the name has a space. Gmail doesn't have any problem with that.

I use this code:

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

Solution

  • I changed o (files[pos].getPath()) to Uri.fromFile(files[pos]).