Send audio file through wpp

0

I would like to know how to send an audio file through wpp, because when I try it appears "failed to share, please try again"

                Intent shareIntent = new Intent(Intent.ACTION_SEND);
                Uri uri = Uri.parse("android.resource://" + getPackageName() + "/raw/badum2.m4a");
                shareIntent.setType("audio/m4a");
                shareIntent.setPackage("com.whatsapp");
                shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
                shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                startActivity(shareIntent);

I used the above code (with some changes) to send through facebook and it worked, but wpp gave this error. Would anyone know how to solve the problem?

    
asked by anonymous 02.12.2016 / 23:52

1 answer

0

You can send audio from your application directly to Whatsapp, like this:

File f = new File("caminho completo do áudio");
Uri uri = Uri.parse("file://"+f.getAbsolutePath());
Intent share = new Intent(Intent.ACTION_SEND);
share.setPackage("com.whatsapp");
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setType("audio/*");
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(Intent.createChooser(share, "Share audio File"));
    
09.12.2016 / 17:13