Using Camera API. Android SDK supports the connectivity to the built-in camera. Using the camera to take photos is relatively easy. It is somewhat harder to setup the camera preview to work properly. In our main activity, we create the Preview object. This object will create the Camera object and return it to the CameraDemo activity. Next we register couple of call-back method with the Camera to be performed when the user takes a photo. shutterCallback is called when the shutter is opened and picture is taken. rawCallback and jpegCallback will get the data for the raw and jpeg encoding of the photo. CameraDemo.java Code: package com.example; import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException; public class CameraDemo extends Activity { private static final String TAG = "CameraDemo"; Camera camera; Preview preview; Button buttonClick; preview = new Preview(this); ((FrameLayout) findViewById(R.id.preview)).addView(preview); Log.d(TAG, "onCreate'd"); } Preview.java.
Dr Android Answers: Saving Camera Pictures to SQL lite « MobileAppDev. Eclipse - How to add a file to an Android project, deploy it to the device, and then open it. Android Application Development Tutorial - 41 - Finish Camera and Wallpaper App. Android Application Development Tutorial - 40 - Getting Data from a different Activity. Android Application Development Tutorial - 39 - Starting an Activity for a Result. Curso Android: Trabajado con imágenes (cámara y galería) En el primer capítulo del curso aprendimos a construir un lector de feeds simple; el segundo capítulo fue sobre UI en Android y aumentar la funcionalidad de un lector de feeds; en el tercer capítulo trabajaremos con el hardware de los teléfonos y empezaremos con el manejo de la cámara.
Mostrar una imagen de la cámara o de la galería La aplicación que realizaremos nos permitirá mostrar una imagen, podemos obtenerla desde la cámara o desde la galería del teléfono. Queremos que al finalizar se vea así: Con una imagen cargada se verá de la siguiente forma: Disposición inicial Empezaremos descargando el código que debe importarse hacia un proyecto nuevo. La etiqueta debe lucir de la siguiente forma: En la parte de diseño vamos a empezar con un RelativeLayout, el archivo /res/layout/main.xmldebe estar así: Diseño Trabajaremos con otra disposición de elementos para el diseño llamado RelativeLayout y agregaremos otros elementos de interfaz de usuario.
El código completo del layout es el siguente: Android Application Development Tutorial - 38 - XML ImageView for Camera Application.