Sharing an Image from Bitmap in Android

I had a project that required downloading an image from the internet then calling the sharing intent to share that bitmap, I went through countless entries until I reached the conclusion that it is impossible to share an image directly from a bitmap object, the bitmap must be saved first and then you can share it and if you dont want to keep a copy on disk you have to explicitly delete it.

Here are how I ended up doing it.

1. Save BitMap

String file_path = Environment.getExternalStorageDirectory().getAbsolutePath() +
"/ProjectName";
File dir = new File(file_path);
if(!dir.exists())
dir.mkdirs();
File file = new File(dir, name);
FileOutputStream fOut;
try {
fOut = new FileOutputStream(file);
abmp.compress(Bitmap.CompressFormat.PNG, 85, fOut);
fOut.flush();
fOut.close();
} catch (Exception e) {
e.printStackTrace();
}

2. Share URI from file

Uri uri = Uri.fromFile(file);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");

intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
intent.putExtra(android.content.Intent.EXTRA_TEXT, "");

intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share Cover Image"));

 

If you can come up with a hack to share directly from BitMap please do share, but I dont believe it is possible.

 

Temboo the on stop shop API

There is no way to capture the value of online APIs, basically they save you from the tedious effort of reinventing the wheel or maintaining a costly back end. Shifting your focus from algorithm to customer experience, the only expense here is integrating the API with your product. While most APIs rely on JSON calls of one kind or another integrating them into your code can be costly and time consuming, especially if you use multiple APIs, also it is quite time consuming to keep track of APIs as they get updated. also there is a certain degree of effort required to learn how to efficiently use each API. (API calls economics)

Temboo is a one stop SDK, providing a single interface for an ever expanding list of APIs and available in 7 languages!

Temboo standardizes the way you interact with an ever expanding list of APIs, updating frequently to match any changes in these APIs keeping your products in sync with them transparently. Basically Temboo is a wrapper that provides a standard API to a bunch of APIs and its available in a bunch of languages. With the end result being the ability to integrate any API you want into your code without spending tedious hours reading their documentation and testing various messages and their responses.

It gets even better, through the website you can test various APIs through a simple web interface, testing various test cases, by filling the variables in text boxes. It even provides you with a code snippet suitable to be plugged directly into your code. Basically saving you hours of testing and integration.

When I mentioned that their APIs list is ever expanding I really meant it, every time I visit the site I can see few more APIs added to the list, they just added twitter, and now I’m considering unifying all my products API usage and piping it through Temboos. I’m rarely that excited about a new product, but this one seriously blew me away.

AND IT SUPPORTS ARDUINO !