I have my code all set and done.. no errors at all..everything looks
fine.. how/where/why doesnt takes a picture? Can anyone help me with
this? this is a internet tutorial custumized for needs..

public class thenNnowMode extends Activity implements
SurfaceHolder.Callback{

        SurfaceView tnnSurfaceView;
        SurfaceHolder mSurfaceHolder;
        Camera tnnCamera;
        boolean mPreviewRunning = false;
        private Context mContext = this;
        ImageView transparencyPreview;
        Bitmap TNNPicture;
        String TNNPicturePath;
        TextView blinktext;
    Animation animation;
    static final int FOTO_MODE = 0;

        public void onCreate(Bundle icicle) {
                        super.onCreate(icicle);

                        requestWindowFeature(Window.FEATURE_NO_TITLE);
                        setContentView(R.layout.thennnowmode);


                        tnnSurfaceView = (SurfaceView)
findViewById(R.id.surface_camera);
                        mSurfaceHolder = tnnSurfaceView.getHolder();
                        mSurfaceHolder.addCallback(this);
                        
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        }

        protected void onRestoreInstanceState(Bundle savedInstanceState){
                super.onRestoreInstanceState(savedInstanceState);
        }

        protected void onResume(){
                super.onResume();
        }

        protected void onSaveInstanceState(Bundle outState){
                super.onSaveInstanceState(outState);
        }

        protected void onStop(){
                super.onStart();
        }

        @Override
        // Create the Surface and Open the Camera
        public void surfaceCreated(SurfaceHolder holder) {
                tnnCamera = Camera.open();
        }

        @Override
        // Reacts for camera changes
        public void surfaceChanged(SurfaceHolder holder, int format, int
w,int h) {
                if (mPreviewRunning) {
                        tnnCamera.stopPreview();
                        }
                        Camera.Parameters p = tnnCamera.getParameters();
                        p.setPreviewSize(w, h);
                        tnnCamera.setParameters(p);
                        try {
                                tnnCamera.setPreviewDisplay(holder);
                        } catch (IOException e) {
                        e.printStackTrace();
                        }
                        tnnCamera.startPreview();
                        mPreviewRunning = true;
        }

        @Override
        // When the camera is closed
        public void surfaceDestroyed(SurfaceHolder holder) {
                tnnCamera.stopPreview();
                mPreviewRunning = false;
                tnnCamera.release();
        }

        // Metodo on click of the screen takes a picture
        public void onClick(View arg0) {
                tnnCamera.takePicture(null, mPictureCallback, mPictureCallback);
        }

        // When the picure is taken. This method gives the byte[] of the
picture
        Camera.PictureCallback mPictureCallback = new
Camera.PictureCallback() {
        public void onPictureTaken(byte[] imageData, Camera c) {
                        if (imageData != null) {
                                Intent mIntent = new Intent();
                                // salva a foto
                                previewAndStoreInfo(mContext, imageData, 50, 
"fotoTirada");
                                tnnCamera.startPreview();
                                setResult(FOTO_MODE, mIntent);
                                finish();
                        }
                }
        };


        public static boolean previewAndStoreInfo(Context mContext, byte[]
imageData,int quality, String expName) {
        File sdImageMainDirectory = new File("/sdcard");
                FileOutputStream fileOutputStream = null;
                String nameFile;
                try {
                        BitmapFactory.Options options=new 
BitmapFactory.Options();
                        options.inSampleSize = 5;
                        Bitmap myImage = 
BitmapFactory.decodeByteArray(imageData, 0,
imageData.length,options);
                        fileOutputStream = new
FileOutputStream(sdImageMainDirectory.toString() +"/" + expName +
".jpg");
                        BufferedOutputStream bos = new
BufferedOutputStream(fileOutputStream);
                        myImage.compress(CompressFormat.JPEG, quality, bos);
                        bos.flush();
                        bos.close();
                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                } catch (IOException e) {
                        e.printStackTrace();
                }
                return true;
        }

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to