本文介绍了Android:MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何ony可以给我指导如何找到我的Android设备从相机存储其图像的目录;

Can any ony give me guidelines on how to find the directory my Android device stores its images takem from a camera;

在下面的代码片段中,我打算在启动相机应用程序之前获取文件列表。从相机应用程序返回时,获取同一目录中所有文件的列表并处理新添加的文件。

In the following code snippet, I intend to get a list of files in prior to launching the camera app. When returning from the camera app get a list of all the files in the same directory and process the newly added ones.

public void onBtnTakePhoto(final View view) {
    existingfiles = UploadImageService.getFiles(<IMAGE_LOCATION>);
    final Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
    startActivityForResult(intent, TAKE_PICTURE);
}


public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
        case TAKE_PICTURE:
            List<String> newFies = UploadImageService.getFiles(<IMAGE_LOCATION>);
            newFies.removeAll(existingfiles);
            for (String newFile : newFies) {
                File file = new File(newFile);
                addImage( Uri.fromFile(file), PictureSource.CAMERA);
            }
            break;
    }
    // regardless of which activity, check that files exist:
    verifyFilesExist(images);
}


推荐答案

据我所知,您实际上必须使用操作(而不是INTENT_ACTION_STILL_IMAGE_CAMERA)。然后,在 onActivityResult 中,您必须从Intent获取数据:在那里您将找到对图像的引用。

As far as I understand it, you actually would have to launch your intent with the ACTION_IMAGE_CAPTURE action (instead of INTENT_ACTION_STILL_IMAGE_CAMERA). Then, in onActivityResult you have to get the data from the Intent: there you will find the reference to the image.

查看给出的示例。

但是当我看到你的答案时,你可能会觉得这更有用:

But as I look at your answer, you probably would find this more useful:

String[] projection = { 
          MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA 
}; 
String selection = ""; 
String[] selectionArgs = null; 
mImageExternalCursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
           projection, selection, selectionArgs, null); 
mImageInternalCursor = 
           managedQuery(MediaStore.Images.Media.INTERNAL_CONTENT_URI, projection,
           selection, selectionArgs, null); 

然后

String filePath = 
            mImageExternalCursor.getString(mImageExternalCursor.getColumnIndexOrThrow(
            Media‌Store.Images.ImageColumns.DATA));

(因为你实际上并不想拍新照片)。

(since you don't actually want to take a new picture).

这篇关于Android:MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 12:05