1
我有这样的代码:安卓:拍照并保存到指定文件夹
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.inventario);
Button scatta=(Button) findViewById(R.id.scatta_foto);
scatta.setOnClickListener(new OnClickListener(){
public void onClick(View v){
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 2);
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 2) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
ImageView test = (ImageView) findViewById(R.id.anteprima);
test.setImageBitmap(photo);
try{
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
String currentDateandTime = sdf.format(new Date()).replace(" ","");
FileOutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/bao/bao"+currentDateandTime+".jpg");
photo.compress(Bitmap.CompressFormat.JPEG, 90, out);
}catch (Exception e){
e.printStackTrace();
}
}
}
我知道它(照片拍摄完成并因为Dropbox的,我敢肯定它的工作),但它不会出现在ImageView和文件管理器中! 我怎样才能把在指定的目录中的照片(/ SD卡/我的应用程序内/)和ImageView的
不会做任何事情 – Zak
它不会在onActivityResult中输入! 也许这是因为我有标签,我用replacecontentview更改视图(但在此之前)? – Zak
但它回到正确的看法,这是奇怪的 – Zak