当我从相机回来时,我的应用程序崩溃了。应用程序在 bellow 19 Android 版本上完美运行,但不适用于 OS 版本 19。我正在使用 google nexus 7 运行此应用程序。
我正在向您发送我的代码:
cameraButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, IMAGE_CAPTURE);
}
});
我的 onActivityResult( 在下面给出):
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
if (requestCode == IMAGE_CAPTURE) {
Uri fileUri = null;
if(imageReturnedIntent == null || resultCode != RESULT_OK){
Log.d("ResultNotOk", "resultCode"+resultCode);
File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString());
for(File f : imageStorageDir.listFiles()){
if(Uri.fromFile(f).equals(this.fileUri)){
fileUri = this.fileUri;
Log.d("fileUriNew", "fileUriNew:-" +fileUri);
break;
}
}
}else if (resultCode == RESULT_OK) {
Log.d("ResultOk!!", "resultCode"+resultCode);
fileUri = imageReturnedIntent.getData();
}
//fileUri = imageReturnedIntent.getData();
Log.d("Uri", "FileUri"+fileUri);
Intent cameraIntent = new Intent(this, EditImage.class);
cameraIntent.setType("/*image");
cameraIntent.setData(imageReturnedIntent.getData());
cameraIntent.putExtra("EditMode", true);
cameraIntent.putExtra("Uri", fileUri);
Log.d("imageReturnedIntent", "imageReturnedIntent"+ imageReturnedIntent);
//if edit mode is 1, intent is from camera
cameraIntent.putExtra("EditMode", false);
startActivity(cameraIntent);
}