Hi i have used SurfaceView and taking picture by below code
First i am starting activity by this code
startActivityForResult(new Intent(PictureEditor.this, CustomCamera.class), CAMERA_REQUEST3);
and then getting result from this code
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == CAMERA_REQUEST3) {
BitmapFactory.Options abc = new BitmapFactory.Options();
abc.inJustDecodeBounds = true;
BitmapFactory.decodeFile((Environment.getExternalStorageDirectory() + File.separator + "tester.png"), abc);
abc.inSampleSize = calculateInSampleSize(abc, w, h) + 1;
abc.inJustDecodeBounds = false;
view.setBackBitmap(BitmapFactory.decodeFile((Environment.getExternalStorageDirectory() + File.separator + "tester.png"), abc));
}
Now the CustomeCamera Class’s code is below
// / Handles when mTakePicture is clicked
private OnClickListener mTakePictureAction = new OnClickListener() {
@Override
public void onClick(View v) {
if (mCamera != null)
mCamera.takePicture(CustomCamera.this);
}
};
Then
@Override
public void takePicture(Activity activity) {
if (mCamera != null)
mCamera.takePicture(shutterCallback, rawCallback, jpegCallback);
Intent returnIntent = new Intent();
activity.setResult(mActivity.RESULT_OK, returnIntent);
activity.finish();
}
the problem is image is captured but the activity is not getting finish! Can anybody suggest me what to do!
you need to write code for finish activity in onActivityResult() in previous activity from where this activity starts.
So your previous activity finish . . .
Edit :
First change this code.
then in onActivityResult() first check the request code condition then after in request code condition check result code condition.