camera picturecallback intent not work
- by Simon
After I take the photo, the program automatically goes back like onBackPressed().
When I remove the putExtra, the intent runs. When I put startActivity() after takePicture(), it transfers null data....
I just want to put the image data to another activity to have other use. How can it be achieved?
private PictureCallback picture = new PictureCallback(){
@Override
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
Intent intent = new Intent(CameraFilming.this, PhotoPreview.class);
intent.putExtra("imageByte", data); //Picture data transfer to next activity
startActivity(intent);
}
};
//take photo by pressing button
private class captureBtnListener implements View.OnClickListener{
@Override
public void onClick(View v){
capture.setOnClickListener(null);
CountDownTimer timer = new CountDownTimer(10000, 1000){
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
countdown.setText(millisUntilFinished/1000+"");
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
countdown.setText("0");
camera.takePicture(null, null, picture);
}
};
timer.start();
}
}
public class PhotoPreview extends Activity{
private RelativeLayout layout;
private ImageView overlay, texture, face1, face2;
@Override
public void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.photo_preview);
layout = (RelativeLayout)findViewById(R.id.preview_layout);
byte[] data = getIntent().getByteArrayExtra("imageByte");
if (data == null){
Log.d("PhotoPreview", "no image data");
finish();
}
Bitmap rawPhotoBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
ImageProcess imgProcess = new ImageProcess(this);
Bitmap resizedFace = imgProcess.scaleAccordingWidth(imgProcess.cropImage(rawPhotoBitmap, 840, 125, 440, 560), 77);
face1 = new ImageView(this);
face1.setImageBitmap(resizedFace);
Log.d("testing", "testing");
}
}