2
我打電話給相機目的並嘗試在SD卡中保存捕獲圖像,但相機意圖給我空數據。我不能理解的問題是什麼。我的代碼如下在SD卡中保存捕獲圖像android
imgBtnPicture.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String fileName="ashraful.jpg";
String root = Environment.getExternalStorageDirectory().toString();
new File(root + "/photofolder").mkdirs();
File outputfile=new File(root+"/photofolder/", fileName);
Uri outputFileUri = Uri.fromFile(outputfile);
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
if(data!=null)
{
Bitmap photo = (Bitmap) data.getExtras().get("data");
Bitmap icon1=ResizeBitmap(photo,200,200);
imgBtnPicture.setImageBitmap(icon1);
}
}
}
但我得到空數據?如何解決我的問題?plz幫助