【问题标题】:What is an URI in android什么是android中的URI
【发布时间】:2017-12-04 19:19:06
【问题描述】:

我最近遇到了一个对我来说毫无意义的 android 对象。我不明白什么是 URI?

好吧,我检查了Official Documentation,它说:

不可变的 URI 引用。 URI 引用包括一个 URI 和一个 片段,URI 的“#”之后的组成部分。构建和解析 符合 RFC 2396 的 URI 引用。

问题是,你不能用 URI 来解释什么是 URI!我完全糊涂了。

我做了一些研究,发现了this article。但它说

Uri 什么都不做

谁能给我解释一下这是什么意思!

【问题讨论】:

标签: android


【解决方案1】:
  1. 问:什么是“URI”?

    A:“URI”的技术含义在RFC 2396中定义:

统一资源标识符 (URI) 是一个紧凑的序列 标识抽象或物理资源的字符。

  1. 问:什么是 Android“URI”类?

    答:这是android.net.Uri的Javadoc

  2. 问:但是我们需要 Android“URI”类做什么?

    A:查看 Android 文档的“Content Providers”部分:

http://developer.android.com/guide/topics/providers/content-providers.html

内容提供商管理对结构化数据集的访问。他们 封装数据,并提供定义数据的机制 安全。内容提供者是连接的标准接口 数据在一个进程中,而代码在另一个进程中运行。

例如...

public final ContentProviderClient acquireContentProviderClient (Uri uri)

返回一个与 ContentProvider 为 uri 上的内容提供服务,启动 必要时提供者。

如果您很好奇,以下是 Tim Berners-Lee 对 URI 的评价(他是 URI 的发明者;)):

http://www.w3.org/DesignIssues/Axioms.html#uri

通用资源标识符

网络是一个通用的信息空间。它是某种意义上的空间 里面的东西有一个地址。 “地址”、“名称”或我们 在这里称它们为标识符,是本文的主题。他们是 称为统一资源标识符 (URI)。

如果信息对象具有 URI,则它是“在网络上”。对象 有 URI 有时被称为“第一类对象”(FCO)。这 当任何具有价值和身份的信息对象是 第一类对象。如果某物没有 URI,则无法引用 对它来说,网络的力量就更小了。

我所说的通用是指网络被声明为能够包含在 原则 网络可访问的每一点信息。它是 旨在能够包括现有的信息系统,如 FTP,并且能够在未来简单地扩展包括 任何新的信息系统。

URI 方案识别事物的各种不同类型的信息 对象,在协议中扮演不同的角色。有的认 服务、连接端点等,但一个基本的 基础架构概念是信息对象 - 否则 称为通用文档。这些可以用字符串表示 位。一个信息对象传达了一些东西——它可能是艺术、诗歌、 传感器值或数学方程。

【讨论】:

  • 一个问题我没能回答: 问:什么是Android“URI 参考”?在 Uri.Builder 的“类概述”部分中查看 here。这也回答了关于“URI”与“URI 片段”的问题。
【解决方案2】:

URI(统一资源标识符)顾名思义,用于标识资源(无论是文本页面、视频或声音剪辑、静止或动画图像还是程序)。

最常见的 URI 形式是网页地址,它是称为统一资源定位器 (URL) 的特定形式或 URI 子集。

Android 使用 URI 字符串作为在内容提供者中请求数据(即检索联系人列表)和请求操作(即在浏览器中打开网页)的基础

【讨论】:

    【解决方案3】:

    我正在从 RFC 添加以缩写 URI 为中心的详细信息以及一些正在使用的示例:

    发件人,
    http://www.faqs.org/rfcs/rfc2396.html

    本文档更新并合并了“统一资源定位符”
    [RFC1738] 和“相对统一资源定位符”[RFC1808] 按顺序 为所有 URI 定义一个单一的通用语法。

    还有,

    1.1 URI概述

    URI 具有以下定义:

      Uniform
         Uniformity provides several benefits: it allows different types
         of resource identifiers to be used in the same context, even
         when the mechanisms used to access those resources may differ;
         it allows uniform semantic interpretation of common syntactic
         conventions across different types of resource identifiers; it
         allows introduction of new types of resource identifiers
         without interfering with the way that existing identifiers are
         used; and, it allows the identifiers to be reused in many
         different contexts, thus permitting new applications or
         protocols to leverage a pre-existing, large, and widely-used
         set of resource identifiers.
    
      Resource
         A resource can be anything that has identity.  Familiar
         examples include an electronic document, an image, a service
         (e.g., "today's weather report for Los Angeles"), and a
         collection of other resources.  Not all resources are network
         "retrievable"; e.g., human beings, corporations, and bound
         books in a library can also be considered resources.
    
         The resource is the conceptual mapping to an entity or set of
         entities, not necessarily the entity which corresponds to that
         mapping at any particular instance in time.  Thus, a resource
         can remain constant even when its content---the entities to
         which it currently corresponds---changes over time, provided
         that the conceptual mapping is not changed in the process.
    
      Identifier
         An identifier is an object that can act as a reference to
         something that has identity.  In the case of URI, the object is
         a sequence of characters with a restricted syntax.
    

    以下是一些正在使用的:

    1.3。示例 URI

    以下示例说明了常用的 URI。

    ftp://ftp.is.co.za/rfc/rfc1808.txt -- 文件传输协议服务的 ftp 方案

    gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles -- Gopher 和 Gopher+ 协议服务的 gopher 方案

    http://www.math.uio.no/faq/compression-faq/part1.html -- 超文本传输​​协议服务的http方案

    mailto:mduerst@ifi.unizh.ch -- 电子邮件地址的 mailto 方案

    新闻:comp.infosystems.www.servers.unix -- USENET 新闻组和文章的新闻方案

    telnet://melvyl.ucop.edu/ -- 通过 TELNET 协议进行交互服务的 telnet 方案

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-03
      • 1970-01-01
      • 2011-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-20
      • 1970-01-01
      相关资源
      最近更新 更多