Question

I have an app that can send a normal intent by calling startActivity with:

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("audio/*");
sharingIntent.setPackage("com.whatsapp");
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(filepath));
startActivity(sharingIntent);

But i want my app on whatsapp attach menu (Audio Item specifically) like this related discussion example: Returning an Image to whatsapp

So, i used the code below, my app is showed on menu but when i do the share steps i get whatsapp "Share failed, please try again" error message. Others similar apps do the steps with the final step showing the Whatsapp Recorder dialog to apply sound on chat.

On this second feature (whatsapp internal intent-filter sharing) i use the same intent but with this:

setResult(RESULT_OK, buildSoundShareIntent(soundId));
finish();

instead of startActivity

Is there something specific and hidden that i dont find?

Était-ce utile?

La solution

The solution is below my noose all the time, its simple: call the Intent constructor with action and data (Uri.fromFile(File)):

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND, Uri.fromFile(file));
setResult(sharingIntent);

Autres conseils

In camera Settings; set storage to "Ext. SD card". Also, move any older photos you want to share to Ext. SD card. This worked perfectly with me. Hope it will work for you.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top