我正在尝试拍照并使用startActivityForResult()将其保存到文件中。但点击“保存”按钮后,它没有保存任何内容,而是再次打开相机。 使用设备三星Galaxy S3(4.1.1)和三星Galaxy Nexus(4.1.1),但它与摩托罗拉Defy(2.3.4)的罚款。 这是Android OS 4.1.1或设备的问题吗?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
File file = null;
Date date = new Date();
try {
file = new File("photosearch-"+date.getTime()+".jpeg");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
Log.e(TAG, " startActivityForResult");
startActivityForResult(intent, CAMERA_ACTIVITY);
} catch (Exception e) {
Log.d(TAG, ""+e);
//Check if sdcard is accessible
Toast.makeText(getActivity(), "Unable to access SD Card", Toast.LENGTH_LONG).show();
getActivity().finish();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult....");
if(resultCode == Activity.RESULT_CANCELED){
Intent intent = new Intent(getActivity(), AnotherListActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
getActivity().finish();
}
if(resultCode == CAMERA_ACTIVITY){
Log.d(TAG, "It should come here..");
}
}