Friday, November 6, 2009

Re: [android-developers] Re: problem reading from the Camera

Hamilton Lima (athanazio) wrote:
> Still with the issue ... :(
>
> tried to create a new project
> with the following code

<snip>

> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
>
> try {
> camera = Camera.open();
> SurfaceView original = (SurfaceView) findViewById(R.id.original);
> Log.i("camera", original.toString() );
> Log.i("camera", original.getHolder().toString() );
>
> camera.setPreviewDisplay(original.getHolder());
> camera.startPreview();
>

The SurfaceView will not be ready by this time. You need to register a
callback with the SurfaceHolder and wait for the surface to be ready.

Here is a sample application demonstrating the technique:

http://github.com/commonsguy/cw-advandroid/tree/master/Camera/Picture/

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_Beginning Android_ from Apress Now Available!

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment