我只是有一个小问题。我成功打开相机,按下按钮拍照后,出现以下三个按钮OK
,RETAKE
和CANCEL
。通常,当按下 OK 按钮时,相机活动应该正常返回到父活动并执行 onActivityResult 函数包含的内容。但在我的情况下,当按下 OK 时,相机活动不会返回到父活动。有什么解决这个问题的建议吗?
请在下面找到代码:
OnClickListener btn_TakePictureListener = new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imgPath = retrievePath();
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri(imgPath));
startActivityForResult(intent, RequestCode);
}
};
//@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//super.onActivityResult(requestCode, resultCode, data);
if (RequestCode == requestCode && resultCode == RESULT_OK) {
String s = data.getDataString();
Toast.makeText(getBaseContext(), ""+s, Toast.LENGTH_SHORT).show();
Toast.makeText(getBaseContext(), "picture is taken", Toast.LENGTH_SHORT).show();
}
}
private String retrieveName() {
int []x = imgOpHlpr.getIDs();
String s = imgOpHlpr.getImg_Name(x.length);
return s;
}
private File retrievePath() {
int []x = imgOpHlpr.getIDs();
String s = Environment.getExternalStorageDirectory().getAbsolutePath();
s += "/myFolder/"+imgOpHlpr.getImg_Path(x.length);
File file = new File(s);
return file;
}
private Uri getImageUri(File path) {
Uri imgFileUri = Uri.fromFile(path);
return imgFileUri;
}