在android中显示图像视图布局中拍摄的最新照片
我正在开发一个应用程序,它可以用我的相机拍摄照片,并将其显示在我的图像视图布局中。因此,任何人都可以告诉我如何访问最新拍摄的照片并显示它。如果有人有同样的问题,我得到了解决方案您可以参考此解决方案在android中显示图像视图布局中拍摄的最新照片,android,Android,我正在开发一个应用程序,它可以用我的相机拍摄照片,并将其显示在我的图像视图布局中。因此,任何人都可以告诉我如何访问最新拍摄的照片并显示它。如果有人有同样的问题,我得到了解决方案您可以参考此解决方案 public void click1(View v){ //define the file-name to save photo taken by Camera activity capturedImageFilePath=null; fileName = System.cur
public void click1(View v){
//define the file-name to save photo taken by Camera activity
capturedImageFilePath=null;
fileName = System.currentTimeMillis()+"";
//create parameters for Intent with filename
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, fileName);
values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera");
//imageUri is the current activity attribute, define and save it for later usage (also in onSaveInstanceState)
imageUri = getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
//create new Intent
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
//use imageUri here to access the image
String[] projection = { MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(imageUri, projection, null, null, null);
int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
capturedImageFilePath = cursor.getString(column_index_data);
imageFile = new File(capturedImageFilePath);
if(imageFile.exists()){
Bitmap bm = BitmapFactory.decodeFile(capturedImageFilePath);
image.setImageBitmap(bm);}
} else if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Picture was not taken", Toast.LENGTH_SHORT);
} else {
Toast.makeText(this, "Picture was not taken", Toast.LENGTH_SHORT);
}
}
}
到目前为止你走了多远?您遇到的确切问题是什么?如何通过修改日期识别图片