我有一个奇怪的问题我无法找到,问题是什么。我需要为我的应用程序获取高分辨率图像。我决定使用内置相机应用程序。我看过这个网站https://developer.android.com/training/camera/photobasics.html,在我看来,我完全一样。但是当我尝试调用startActivityForResult时,我的应用程序立即崩溃。我已经读过我需要使用onSaveInstanceState(),但在拍摄图像之前它不会立即被粉碎。拜托,你能告诉我,有什么不对。
这是一段代码:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode==TAKE_PHOTO_REQUEST){
if (resultCode!=RESULT_OK) return;
// to know call was successful
Toast.makeText(this, "Result received", Toast.LENGTH_LONG).show();
}
}
private static final String TAKEN_PHOTO_FILE_NAME="/_TAKEN_IMAGE_.jpg";
private Uri takenImageUri;
protected void button_takePhoto_click(View v){
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File outImage = new File(getExternalStorageDirectory().getAbsolutePath() + TAKEN_PHOTO_FILE_NAME);
takenImageUri=Uri.fromFile(outImage);
// if I comment line below out, everything works.
intent.putExtra(MediaStore.EXTRA_OUTPUT, takenImageUri);
startActivityForResult(intent, TAKE_PHOTO_REQUEST);
}
答案 0 :(得分:0)
在owerridable body后添加super.onActivityResult(args...)
。