Can you be more specific on what's not working?

--
Jack Ha
Open Source Development Center
・T・ ・ ・Mobile・ stick together

The views, opinions and statements in this email are those of
the author solely in their individual capacity, and do not
necessarily represent those of T-Mobile USA, Inc.



On Jul 18, 9:19 pm, kurosagi <[email protected]> wrote:
> my code
>
> import java.io.IOException;
>
> import android.app.Activity;
> import android.content.Intent;
> import android.graphics.Canvas;
> import android.graphics.Paint;
> import android.graphics.PixelFormat;
> import android.graphics.Rect;
> import android.net.Uri;
> import android.os.Handler;
> import android.os.Message;
> import android.os.Bundle;
> import android.provider.MediaStore.Images;
> import android.provider.MediaStore.Video;
> import android.view.Menu;
> import android.view.MenuItem;
> import android.view.SurfaceHolder;
> import android.view.SurfaceView;
> import android.view.KeyEvent;
> import android.hardware.Camera;
>
> import android.util.Log;
>
> public class gtest extends Activity implements
> SurfaceHolder.Callback
> {
>     private static final String TAG = "CameraApiTest";
>     Camera mCamera;
>     boolean mPreviewRunning = false;
>
>     public void onCreate(Bundle icicle)
>     {
>         super.onCreate(icicle);
>
>         Log.e(TAG, "onCreate");
>
>         getWindow().setFormat(PixelFormat.TRANSLUCENT);
>
>         setContentView(R.layout.main);
>         mSurfaceView = (SurfaceView)findViewById(R.id.surface);
>
>         mSurfaceHolder = mSurfaceView.getHolder();
>         mSurfaceHolder.addCallback(this);
>         mSurfaceHolder.setType
> (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
>     }
>
>     public boolean onCreateOptionsMenu(android.view.Menu menu) {
>         MenuItem item = menu.add(0, 0, 0, "goto gallery");
>         item.setOnMenuItemClickListener(new
> MenuItem.OnMenuItemClickListener() {
>             public boolean onMenuItemClick(MenuItem item) {
>                 Uri target = Uri.parse("content://media/external/
> images/media");
>                 Intent intent = new Intent(Intent.ACTION_VIEW,target);
>                 startActivity(intent);
>                 return true;
>             }
>         });
>         return true;
>     }
>
>     @Override
>     protected void onRestoreInstanceState(Bundle savedInstanceState)
>     {
>         super.onRestoreInstanceState(savedInstanceState);
>     }
>
>     Camera.PictureCallback mPictureCallback = new
> Camera.PictureCallback() {
>         public void onPictureTaken(byte[] data, Camera c) {
>             Log.e(TAG, "PICTURE CALLBACK: data.length = "
> +data.length);
>             mCamera.startPreview();
>         }
>     };
>
>     public boolean onKeyDown(int keyCode, KeyEvent event)
>     {
>         if (keyCode == KeyEvent.KEYCODE_BACK) {
>             return super.onKeyDown(keyCode, event);
>         }
>
>         if (keyCode == KeyEvent.KEYCODE_SPACE) {
>             mCamera.takePicture(null,null, mPictureCallback);
>             return true;
>         }
>
>         return false;
>     }
>
>     protected void onResume()
>     {
>         Log.e(TAG, "onResume");
>         super.onResume();
>     }
>
>     protected void onSaveInstanceState(Bundle outState)
>     {
>         super.onSaveInstanceState(outState);
>     }
>
>     protected void onStop()
>     {
>         Log.e(TAG, "onStop");
>         super.onStop();
>     }
>
>     public void surfaceCreated(SurfaceHolder holder)
>     {
>         Log.e(TAG, "surfaceCreated");
>         mCamera = Camera.open();
>         //mCamera.startPreview();
>     }
>
>     public void surfaceChanged(SurfaceHolder holder, int format, int
> w, int h)
>     {
>         Log.e(TAG, "surfaceChanged");
>
>         // XXX stopPreview() will crash if preview is not running
>         if (mPreviewRunning) {
>             mCamera.stopPreview();
>         }
>
>         Camera.Parameters p = mCamera.getParameters();
>         p.setPreviewSize(w, h);
>         mCamera.setParameters(p);
>         try {
>                         mCamera.setPreviewDisplay(holder);
>                 } catch (IOException e) {
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>         mCamera.startPreview();
>         mPreviewRunning = true;
>     }
>
>     public void surfaceDestroyed(SurfaceHolder holder)
>     {
>         Log.e(TAG, "surfaceDestroyed");
>         mCamera.stopPreview();
>         mPreviewRunning = false;
>         mCamera.release();
>     }
>
>     private SurfaceView mSurfaceView;
>     private SurfaceHolder mSurfaceHolder;
>
> }
>
> Help please
>
> Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to