Hi there,
I have a cameraView class which shows me the Cam View with a button
placed on the corner.
Once I click that button I'd like to go to another activity which also
contains the camera view but some other properties. My code is giving
me an undetectable error. I'm not sure what to do. Here is the
cameraView class and the thenNnowMode.class which my intent is calling
is exactly the same ... but will load a picture in front of the camera
view instead of having a button. Anyway, is there something I should
do with the cam before moving to another activity that uses cam?
public class cameraView extends Activity implements
SurfaceHolder.Callback{
SurfaceView mSurfaceView;
SurfaceHolder mSurfaceHolder;
Camera mCamera;
boolean mPreviewRunning=false;
private Context mContext = this;
ImageView transparencyPreview;
Bitmap findPicture;
private Button ThenNnowMode;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.camview);
Bundle w = getIntent().getExtras();
findPicture = w.getParcelable("bitmap");
final String picId = w.getString("id");
final String picDate = w.getString("date");
final String picKeywords = w.getString("keywords");
final String picComments = w.getString("comments");
mSurfaceView = (SurfaceView)
findViewById(R.id.surface_camera);
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
ThenNnowMode = (Button) findViewById(R.id.thennnowmode);
ThenNnowMode.setOnClickListener(new
View.OnClickListener() {
public void onClick(View v) {
// PUT THE USER
IN THE THENNNOW MODE
Intent TNNIntent = new
Intent(v.getContext(),
thenNnowMode.class);
Bundle f = new Bundle();
String activityName =
"cameraView";
f.putString("activity",
activityName);
f.putParcelable("bitmap", findPicture);
f.putString("id",
picId);
f.putString("date",
picDate);
f.putString("keywords",
picKeywords);
f.putString("comments",
picComments);
TNNIntent.putExtras(f);
startActivity(TNNIntent);
//surfaceDestroyed(mSurfaceHolder);
finish();
}
});
}
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) {
mCamera = Camera.open();
}
@Override
// Reacts for camera changes
public void surfaceChanged(SurfaceHolder holder, int format, int
w,int h) {
if (mPreviewRunning) {
mCamera.stopPreview();
}
Camera.Parameters p = mCamera.getParameters();
p.setPreviewSize(w, h);
mCamera.setParameters(p);
try {
mCamera.setPreviewDisplay(holder);
} catch (IOException e) {
e.printStackTrace();
}
mCamera.startPreview();
mPreviewRunning = true;
}
@Override
// When the camera is closed
public void surfaceDestroyed(SurfaceHolder holder) {
mCamera.stopPreview();
mPreviewRunning = false;
mCamera.release();
}
// 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) {
// o que acontece kd a foto é tirada (ver no exemplo
downloads/Pictures
}
};
}
--
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