Share Image Intent with custom Save To Gallery option
<p>I am using Android's default share intent to share an image to other apps. But I would like to add an option like <code>Save to Gallery</code> which saves that Image directly to Gallery in media or images or my app's folder. </p>

<p>Currently I am using the simple code to share image:</p>

<pre><code>Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
shareIntent.setType("image/jpeg");
startActivity(Intent.createChooser(shareIntent, "Share to"));
</code></pre>

<p>When I tried WhatsApp's share button from profile picture, there is an option of "<code>Save To Gallery</code>" Option. Now, I came to know that, it is not pre-build in android. That is the manual action added by WhatsApp which somehow saves an image to specific path. On Long pressing that "<code>Save to gallery</code>" button shows that, that action is of WhatsApp's app. So that means WhatsApp has written some logic for it. It is the same default <code>ACTION_SEND</code> intent with <code>image/*</code> mime type with an additional custom action "<code>Save to Gallery</code>".</p>

<p>That's totally fine. I want to add that kind of logic for my app, too. I can register <code>&lt;intent-filter&gt;</code> which can handle this action but it will globally accept any image from any app to save to gallery. </p>

<p>How can I add a manual action for my sharing Intent or <code>&lt;intent-filter&gt;</code> activity which can be specific to my app only (visible by my app only) and serves the purpose of saving an Image to Gallery?</p>