什么是开放的Andr​​oid中? [英] What is Uri in Android?

查看:191
本文介绍了什么是开放的Andr​​oid中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题似乎是愚蠢的,但,我写一个关于相机的API为Android论文。
现在我在看一个SD卡保存图像,但我
有点无所适从URI是并执行。
它从相机到ImageView的解析图像?
它是图像的路径?

我发现了一个教程,但它并没有描述的URI是什么。

中的URI code

 开放的URI;最终静态INT MEDIA_TYPE_IMAGE = 1;URI = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);公共乌里getOutputMediaFileUri(整型){
        返回Uri.fromFile(getOutputMediaFile(类型));
    }


解决方案

在您的情况下,开放的我们什么也不做,但你在 getOutputMediaFile(类型)方法来创建指向媒体文件。我认为你正在使用此 HTTP://www.androidhive。信息/ 2013/09 / Android的工薪用相机-API / 教程。正如你在执行 getOutputMediaFile的见(类型)它会在 Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)新的子目录和文件

这意味着,所有的图像将被存储在这个特定的存储

要显示的图片,您可以使用<一个href=\"http://developer.android.com/reference/android/widget/ImageView.html#setImageURI%28android.net.Uri%29\"相对=nofollow> imageView.setImageUri()。

This question might seem stupid but, I am writing a dissertation about camera API for Android. Right now I'm looking at saving images on a SD Card, but I'm a bit confused about what Uri is and does. Does it parse the image from the camera to the imageView? Is it the path of the image?

I found a tutorial, but it doesn't describe what the Uri is.

The Uri in the code

Uri uri;

final static int MEDIA_TYPE_IMAGE = 1;

uri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

public Uri getOutputMediaFileUri(int type) {
        return Uri.fromFile(getOutputMediaFile(type));
    }

解决方案

In your case Uri does nothing but points to media file which you create in getOutputMediaFile(type) method. I think you are using this http://www.androidhive.info/2013/09/android-working-with-camera-api/ tutorial. As you can see in implementation of getOutputMediaFile(type) it creates new subdirectory and file in Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)

It means that all your images would be stored in this particular storage

To show picture you can use imageView.setImageUri().

这篇关于什么是开放的Andr​​oid中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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