我有2个活动A和B. 在活动A中,我开始活动B.在活动B上,我想拍照并返回活动A并进行下一步。
在活动A中我有:
Intent intent1 = new Intent(this, CameraActivity.class);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(intent1, REQUEST_CAMERA);
在活动B中我有
buttonClick.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
camera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
camera.takePicture(shutterCallback, rawCallback, jpegCallback);
startActivity();
}
});
}
});
private void startActivity(){
Intent output = new Intent();
output.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
setResult(REQUEST_CAMERA, output);
finish();
}
在活动A上,我有:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == SELECT_FILE) {
onSelectFromGalleryResult(data);
} else if (requestCode == REQUEST_CAMERA) {
onCaptureImageResult(data);
}
}
}
我不知道活动B如何放置fileUri并在活动A上启动好方法
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
new ImageTask().execute(data);
clearCamera();
}
};
答案 0 :(得分:2)
Intent output = new Intent();
output.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
setResult(RESULT_OK, output);//change this
finish();