You can check this project here . I havent updated it for quite long time ;) but it will suit your need
STEPS
1.Create a new project in android , right click on it and Choose Android and now click add at the bottom to add the "Library" project to your project
2.Place these permission in your Manifest file
<uses-features android:name="android.hardware.camera"/>
<uses-permission android:name="android.permission.CAMERA"/>
and also this activity under the application tag
<activity android:name="com.camera.library.CameraLibrary"></activity>
3.Now get the instance of the class
CameraOptions options = CameraOptions.getInstance(this);
options.takePicture();
on the click event of button or in any activity call use to start the camera
Intent intent = new Intent(this,CameraLibrary.class); startActivityForResult(intent, REQUEST_CODE);
Call the
options.getBitmapFile()
method to get the bitmap image when user takes the picture or use theoptions.getFilePath()
method to get the file path
The images created are stored in the cache directory of the application
EDIT
Change your code like this
public class UploadImage extends Activity implements OnClickListener {
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
private CameraOptions options;
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
options = CameraOptions.getInstance(UploadImage.this);
options.takePicture();
options.setRequesCode(CAMERA_REQUEST);
Intent intent = new Intent(UploadImage.this,CameraLibrary.class);
startActivityForResult(intent, CAMERA_REQUEST);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
imageView.setImageBitmap(options.getBitmapFile());
}
}
}