Okn
Okn

Reputation: 698

Android - Share Bitmap in Facebook, Twitter, ... Without saving in storage

How can I share Bitmap in Facebook, Twitter, Mail, ... without saving the image in the internal or external storage ?

Upvotes: 0

Views: 376

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006869

First, I would temporarily write your bitmap to external storage, and use that to debug your basic share-the-file logic.

Then, implement a ContentProvider, where you override openFile() and serve up your byte[] of PNG (or JPEG or whatever). Then use a content:// Uri pointing at your ContentProvider in your ACTION_SEND Intent, instead of a Uri pointing at external storage.

This sample project demonstrates the basic structure. In my case, I am serving a file from assets, rather than from memory, so you would change that portion of the logic. Also, I am using the ContentProvider for an ACTION_VIEW request instead of ACTION_SEND, so there would need to be changes there.

How well this will work will depend on how quickly the third-party app will read in the contents from your provider and whether you can arrange to hold onto the bitmap in memory that long.

Upvotes: 1

Related Questions