我有主要的活动类,我在其中编写了这样的 takePicturefromCamera() 方法:
public void takePicturefromCamera() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
try {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
mImageCaptureUri = Uri.fromFile(mFileTemp);
}
else {
// The solution is taken from here: http://stackoverflow.com/questions/10042695/how-to-get-camera-result-as-a-uri-in-data-folder
mImageCaptureUri = InternalStorageContentProvider.CONTENT_URI;
}
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
intent.putExtra("return-data", true);
startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE);
} catch (ActivityNotFoundException e) {
Log.d("TAG", "cannot take picture", e);
}
}
现在我有另一个类,我正在做一些裁剪部分,我的要求是,如果在裁剪用户觉得他想要拍摄另一张照片而不是以前的照片时,我想在某个按钮单击时调用主活动类的 takePicturefromCamera() 方法. 谁能帮助我,我该怎么做。我试过这样做:
retake_button.setOnClickListener(
new View.OnClickListener() {
public void onClick(View v) {
// setResult(RESULT_CANCELED);
main m = new main();
m.takePicturefromCamera();
}
});
但它给了我错误 NullPointerExceptionmImageCaptureUri = Uri.fromFile(mFileTemp);
请帮我。