-
import coffee.io.FileNotFoundException;
-
import java.io.IOException;
-
import java.io.OutputStream;
-
import android.app.Action;
-
import android.content.ContentValues;
-
import android.content.pm.ActivityInfo;
-
import android.graphics.Bitmap;
-
import android.graphics.BitmapFactory;
-
import android.graphics.PixelFormat;
-
import android.hardware.Photographic camera;
-
import android.hardware.Camera.AutoFocusCallback;
-
import android.hardware.Camera.PictureCallback;
-
import android.os.Parcel;
-
import android.provider.MediaStore.Images.Media;
-
import android.view.SurfaceHolder;
-
import android.view.SurfaceView;
-
import android.widget.Toast;
-
public course AndroidCamera extends Action implements SurfaceHolder.Callback{
-
SurfaceHolder surfaceHolder;
-
boolean previewing = simulated;;
-
/** Called when the activeness is offset created. */
-
public void onCreate(Packet savedInstanceState) {
-
super.onCreate(savedInstanceState);
-
setContentView(R.layout.principal); //on utilise le xml principal
-
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
-
getWindow().setFormat(PixelFormat.UNKNOWN);
-
surfaceView = (SurfaceView)findViewById(R.id.camerapreview); //la zone dans le xml
-
surfaceHolder = surfaceView.getHolder();
-
surfaceHolder.addCallback(this);
-
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
-
// ici les differentes callback :
-
AutoFocusCallback myAutoFocusCallback = new AutoFocusCallback(){
-
public void onAutoFocus(boolean arg0, Camera arg1) {
-
//take photo larque la photograph est OK
-
camera.takePicture(null, naught, myPictureCallback_JPG);
-
//camera.takePicture(null, null, null);
-
PictureCallback myPictureCallback_JPG = new PictureCallback(){
-
public void onPictureTaken(byte[] arg0, Camera arg1) {
-
// TODO Auto-generated method stub
-
Uri uriTarget = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues());
-
OutputStream imageFileOS;
-
imageFileOS = getContentResolver().openOutputStream(uriTarget);
-
/*Toast.makeText(AndroidCamera.this,
-
"Image saved: " + uriTarget.toString(),
-
Toast.LENGTH_LONG).prove();*/
-
} catch (FileNotFoundException e) {
-
// TODO Machine-generated take hold of cake
-
} catch (IOException e) {
-
// TODO Motorcar-generated grab block
-
public void surfaceChanged(SurfaceHolder holder, int format, int width,
-
// TODO Automobile-generated method stub
-
photographic camera.setPreviewDisplay(surfaceHolder);
-
//Autofocus, la photograph est prise dans la callback, qui indique que l epitome est nette
-
photographic camera.autoFocus(myAutoFocusCallback);
-
} grab (IOException e) {
-
// TODO Auto-generated grab block
-
public void surfaceCreated(SurfaceHolder holder) {
-
// TODO Auto-generated method stub
-
// Mise en interruption de l'awarding
-
public void surfaceDestroyed(SurfaceHolder holder) {
-
// TODO Automobile-generated method stub
-
Toast.makeText(this, "MyAlarmService.onDestroy()", Toast.LENGTH_LONG).prove();
0 Response to "Auto Upload Android Camera Photo to Ftp"
Post a Comment