Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serving up Images through a Content Provider in Android

So in my app, the user will find images, kind of like the concept art feature in video games. I want these images to be able to be zoomed, shared, and whatever-ed - like in the gallery app. What's the best way to display them? I think the right way to do this is to send a Intent.ACTION_VIEW with a type of image/png, so any program can get it....

But in that case, the images need to be available to any application, they can't be a resource, right? (Because then they wouldn't be available to other apps.) So they need to be available via a Content Provider...

I don't think I can just stick them in the default media Content Provider... because wouldn't they then be discoverable through the gallery app? I want the user to 'unlock' them over time. So I need to build my own content provider, and publish the images through that, right? What's the best way to make a Content Provider that can serve up images (and videos, audio, maybe contacts or other types of objects)?

like image 571
Tom Ritter Avatar asked Jun 26 '11 23:06

Tom Ritter


1 Answers

I would suggest you create your own ContentProvider and handle all business logic there. Images won't be accessible to the gallery app unless they are inserted into the Media Content Provider. You can do this by a manual insert performed within your Content Provider or let the MediaScanner automatically find the files, if you store them in a public directory on the device, and insert them over time.

like image 105
siamii Avatar answered Oct 05 '22 13:10

siamii