Android share image Intent: WhatsApp - The file format is not supported
<p>I've problems with sharing images from my App to WhatsApp.</p>

<pre><code>int imageId = getResources().getIdentifier("image_name", "drawable", getPackageName());

Uri imageUri = Uri.parse("android.resource://com.companyname.packagename/drawable/"+ imageId);

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/jpeg");                       
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "send"));
</code></pre>

<p>This code works fine with Facebook Messenger or Androids build in messenger. 
But it doesn't work with WhatsApp. I get this error message:</p>

<p>"The file format is not supported!"</p>

<blockquote>
  <p>I've solved this problem by using @CommonsWare solution:
  <a href="https://github.com/commonsguy/cwac-provider" rel="noreferrer">https://github.com/commonsguy/cwac-provider</a> </p>
</blockquote>