// private File file;
// c_img = (ImageView) findViewById(R.id.c_img);
file = new File(
Environment.getExternalStorageDirectory().getAbsoluteFile()
+ "/" + getTime() + ".jpg");
iImg.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(iImg, 1);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == 1) {
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
c_img.setImageBitmap(bitmap);
}
}
// getTime()返回当前的本地时间。
// xml是:
<ImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:id="@+id/c_img"/>
谢谢!