'trying to share a file .amr with whatsapp - The file format is not supported
I'm not able to share an .amr file via whatsapp using API 29+, here is my code:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setType("audio/*");
Uri uri=Uri.parse(nomeFile); //nomeFile contains the full path of my file in "/data/data..."
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Choose your app..."));
this returns "The file format is not supported",
I also tried to put my file in an array and drop it into the intent this way
File f = new File(nomeFile);
byte[] buffer = new byte[(int) f.length()];
try {
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(f));
bufferedInputStream.read(buffer, 0, buffer.length);
bufferedInputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
shareIntent.putExtra("com.myapp.myapp.file.amr", buffer);
but the result is "sharing failed please try again"
any help is very appreciated, thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
