我有这些代码。打开相机,拍照,但是当我点击“确定”按钮时,什么也没发生。回到以前的活动的唯一方法是单击对我没有用的“x”按钮:)。问题是什么?(onActivityResult 方法尚未完成。)(我曾经将此算法与Android.provider.MediaStore.ACTION_IMAGE_CAPTURE意图一起使用。一切正常。我不知道为什么我现在有问题。)
public void onClick(View v) {
Intent getCameraImage = new Intent("android.media.action.IMAGE_CAPTURE");
db.open();
Cursor cr = db.getAllRecords();
int count = cr.getCount();
db.close();
File cameraFolder;
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
cameraFolder = new File(android.os.Environment.getExternalStorageDirectory(),"TSFC");
else
cameraFolder= ShowMessagesPage.this.getCacheDir();
if(!cameraFolder.exists())
cameraFolder.mkdirs();
File photo = new File(Environment.getExternalStorageDirectory(), "TSFC/" + (count + 1) + ".jpg");
getCameraImage.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
initialURI = Uri.fromFile(photo);
startActivityForResult(getCameraImage, CAMERA_RESULT);
}});}
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_OK) {
Bundle extras = intent.getExtras();
photo = (Uri) extras.get("data");
}
}