If you've been following my blog, you'll know that I have been working on an Android app called Drawsaur using PhoneGap. I wanted to implement a way for users to share their drawings with other in the same way you share other content on Android. That lead me to a plugin for sharing content. The problem was that it did not quite work for me following the directions out of the box. However, I had previously used a plugin in my application. So I combined that with what was given to me to get it to work. I also had to extend the plugin because it was only written to share text and I, of course, wanted to share images.

Here is the method I implemented to get the file to share. I seem to be having an issue with sharing the image to Google+ but everything else (I tested Dropbox, Twitter, Gmail, and Instagram) worked fine.

private void doSendIntent(String fileName) {
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);

sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Drawsaur");
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Check out my drawing I made with Drawsaur!");
Uri uriFile = Uri.fromFile(new File(fileName));
sendIntent.putExtra(android.content.Intent.EXTRA_STREAM, uriFile);

this.cordova.startActivityForResult(this, Intent.createChooser(sendIntent, "Share Drawsaur Image Using"), 0);