Categories

Guide: Android: Use Camera Activity for Thumbnail and Full Size Image:

Today I have decided to show you how to use the build in camera Activity to
Take thumbnail and full size images. The reason for that is that this is a common problem
and many people get confused as for why do they get a low resolution image when they are
using the build in camera Activity for taking images in their Android application
(I was one of those people).

But first I would like to stop and explain why do you need thumbnail images in your app.
The problem with mobile devices as we all know is that they are low on resources (CPU,
Memory, Storage, etc.. today clearly this statement becomes less and less true), as for this
reason the Android OS was designed to allow a single application use only a very limited
amount of memory at run time.

That means that you can’t take a full 5 or 8 megapixels image and load it into memory just to
show it inside a small ImageView. Well, you can, but on the second or third image your
application will simply crash with an java.lang.OutOfMemoryError. So clearly you have
to care always to use the image with the most low resolution but yet satisfies with it quality at run time.

Back to where I started, people get confused because there are several ways to perform this
operation and I will show you them today:

Thumbnail Image:

Actually this will be the easiest way to take an image using the camera and to save it in
you application. The problem with this is that this image is very low resolution and is
not fit for displaying on a full mobile screen:

You can see that in this case we are getting our image from the Extras of the intent under
the “data” key. We cast it to a Bitmap and save it to a file using an FileOutputStream.
But actually we didn’t had to save it to file and could use the bitmap straight forward.

Full Size Image:

Well the big difference here is if we want to produce a high quality image from the
camera Activity we don’t have a choice but to save it into file and then use:

1. So First of all as before we need to create a static int that will be our requestCode:

@Anas Hey, I’m sorry but this is not possible. This code is a part of a bigger project that belongs to a company I worked at. So this code belongs to them and con’t be published. What more I don’t even have access to it anymore. So sorry, but this could not be done.