如何让机器人与相机拍摄的最后一张图像? [英] How to get last image captured with camera in android?

查看:159
本文介绍了如何让机器人与相机拍摄的最后一张图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目的不是要拍张照片,然后将其保存到SD卡,获取链接和所有。图像已经与抽放在Android原相机应用。

My intention is not to take a picture and then save it to sd card , get the link and all. The image is already taked with the original camera app in the android.

我需要它,我怎么可以得到图像路径相对于SD卡像

All i need it how can i get that image path with respect to sd card like

模拟/ 0 / SD卡/ DCIM / 100ANDRO / image.jpg的

emulated/0/sdcard/DCIM/100ANDRO/image.jpg

我如何得到最近拍摄的图像的该格式。

how do i get that format of the recently taken image.

推荐答案

从URI使用此获取文件的路径:

Use this to get path of file from URI:

Uri selectedImageUri = data.getData();
selectedImagePath = getRealPathFromURI(selectedImageUri);

    public String getRealPathFromURI(Context context, Uri contentUri) {
  Cursor cursor = null;
  try { 
    String[] proj = { MediaStore.Images.Media.DATA };
    cursor = context.getContentResolver().query(contentUri,  proj, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
  } finally {
    if (cursor != null) {
      cursor.close();
    }
  }
}

光标提供对数据库查询返回的结果集的随机读写权限。

Cursor provides random read-write access to the result set returned by a database query.

getContentResolver()返回您的应用程序包中的 ContentResolver的实例。

getContentResolver () returns a ContentResolver instance for your application's package.

当你想在内容提供商来访问数据,可以使用ContentResolver的对象在应用程序的语境与供应商作为客户端进行通信。该ContentResolver的对象与提供者对象,实现ContentProvider的一个类的实例通信。该提供对象从客户端接收数据的请求,执行所请求的动作,并返回结果。

内容解析器包括CRUD(创建,读取,更新,删除),对应于内容提供商类的抽象方法(插入,删除,查询,更新)的方法。内容解析器不知道它与交互(也不需要知道)的内容提供商的执行情况;每个方法传递一个URI指定内容提供商进行交互。

The Content Resolver includes the CRUD (create, read, update, delete) methods corresponding to the abstract methods (insert, delete, query, update) in the Content Provider class. The Content Resolver does not know the implementation of the Content Providers it is interacting with (nor does it need to know); each method is passed an URI that specifies the Content Provider to interact with.

MediaStore:媒体提供包含内部和外部存储设备的所有可用的媒体元数据。 MediaStore.images 包含的元数据所有可用的图像。

MediaStore: The Media provider contains meta data for all available media on both internal and external storage devices. MediaStore.images contains meta data for all available images.

这篇关于如何让机器人与相机拍摄的最后一张图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆