Camera Preview not working on my G2

by Stephen Lebed » Wed, 20 Oct 2010 13:15:12 GMT


Sponsored Links
 'm trying to get the camera preview running on my G2.

This is the code I'm testing with, which was taken from the sample
code. It is using supplemental code supplied by Wu-Cheng, but its
still throwing an error


/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.sltools;

import android.app.Activity;
import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.Window;
import java.io.IOException;
import java.util.List;

//
----------------------------------------------------------------------

public class CameraPreview extends Activity {
private Preview mPreview;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Hide the window title.
requestWindowFeature(Window.FEATURE_NO_TITLE);

// Create our Preview view and set it as the content of our
activity.
mPreview = new Preview(this);
setContentView(mPreview);
}


}

//
----------------------------------------------------------------------

class Preview extends SurfaceView implements SurfaceHolder.Callback {
SurfaceHolder mHolder;
Camera mCamera;

Preview(Context context) {
super(context);

// Install a SurfaceHolder.Callback so we get notified when
the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}

public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, acquire the camera and tell
it where
// to draw.
mCamera = Camera.open();
try {
mCamera.setPreviewDisplay(holder);
} catch (IOException exception) {
mCamera.release();
mCamera = null;
// TODO: add more exception handling logic here
}
}

public void surfaceDestroyed(SurfaceHolder holder) {
// Surface will be destroyed when we return, so stop the
preview.
// Because the CameraDevice object is not a shared resource,
it's very
// important to release it when the activity is paused.
mCamera.stopPreview();
mCamera.release();
mCamera = null;
}

public void surfaceChanged(SurfaceHolder holder, int format, int
w, int h) {
// Now that the size is known, set up the camera parameters and
begin
// the preview.
Camera.Parameters parameters = mCamera.getParameters();

List<Size> sizes = parameters.getSupportedPreviewSizes();
Size optimalSize = getOptimalPrevi



Camera Preview not working on my G2

by TreKing » Wed, 20 Oct 2010 23:19:47 GMT


 



Does it not tell you which class was not found? That would be helpful :-)

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

--


Sponsored Links


Camera Preview not working on my G2

by Stephen Lebed » Thu, 21 Oct 2010 12:27:53 GMT


 Hi TreKing,

Two things

1) The logcat says Runtime exception: Cannot instantiate activity
ComponentInfo.  I'm not sure what that is supposed to mean.  Maybe you
could shed some insight on this.
2) How does someone change the discussion subject?  I can't believe
someone get comes in and hijacks my thread.

Best,
Stephen Lebed







--



Camera Preview not working on my G2

by TreKing » Thu, 21 Oct 2010 22:49:07 GMT


 



Is there any more to the log cat? Post the 5 - 10 lines above and below that
error. Also look for "cause by" in the message and post the 5 - 10 lines
above and below THAT.



I think that's yet another bug with Google Groups. I'm reading this thread
in Gmail and it's currently just you and me :-)

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

--



Other Threads

1. Using the touchscreen and trackball with the GLSurfaceView

I've run into an issue where performing a lot of touch events seem to
block the move events from the trackball.
Anyone else run into this issues?
I can't use the Thread.sleep() fix because that will obviously stop
all input, so I'm hoping someone has been able to throttle the touch
command without effecting the move ones.
--~--~---------~--~----~------------~-------~--~----~

2. Image capture

Using :
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, GET_IMAGE_FROM_CAMERA);

is possibile to run the camera capture application, but I didn't
understand how get the image file info or data on onActivityResult.

somebody know how do it ?

thanks

--~--~---------~--~----~------------~-------~--~----~

3. widget cell 2*1, width is 160 but takes 3*1 cells

4. How to reference native android drawable in the layout XML ?

5. Emulator Listening Socket Fail

6. "We want to feature your app"

7. ppp daemon not startin