I\'ve written a program in Java that takes in an image file and manipulates the image. Now I\'m trying to access the camera so that I can take the photo and give it to the image
Google is your best friend, here are some tutorials:
Using the camera
How-To Program The Google Android Camera To Take Pictures
Take Picture from Camera Emulator
camera
First edit your AndroidManifest.xml, add the camera permission:
Camera service has to be opened and closed:
Camera camera = Camera.open();
//Do things with the camera
camera.release();
You can set camera settings, e.g.:
Camera.Parameters parameters = camera.getParameters();
parameters.setPictureFormat(PixelFormat.JPEG);
camera.setParameters(parameters);
To take a picture:
private void takePicture() {
camera.takePicture(shutterCallback, rawCallback, jpegCallback);
}
ShutterCallback shutterCallback = new ShutterCallback() {
public void onShutter() {
// TODO Do something when the shutter closes.
}
};
PictureCallback rawCallback = new PictureCallback() {
public void onPictureTaken(byte[] _data, Camera _camera) {
// TODO Do something with the image RAW data.
}
};
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] _data, Camera _camera) {
// TODO Do something with the image JPEG data.
}
};
Do not forget to add the camera layout to your main layout xml.