What is Uri.parse in android

2019-03-11 04:22发布

What is the function of Uri and how is Uri.parse() used?

For example :

Uri.parse("tel:(+49)12345789"));

and

Uri.parse("geo:50.123,7.1434?z=19"));

What dotel and geo refer to ?

3条回答
Bombasti
2楼-- · 2019-03-11 04:35

In case you want specific answer about the nature of uriString that is an argument here,
From,
http://developer.android.com/reference/android/net/Uri.html#parse%28java.lang.String%29

Immutable URI reference. A URI reference includes a URI and a fragment, the component of the URI following a '#'. Builds and parses URI references which conform to RFC 2396.

And About RFC 2396 standard,
From,
http://www.faqs.org/rfcs/rfc2396.html

This document updates and merges "Uniform Resource Locators"
[RFC1738] and "Relative Uniform Resource Locators" [RFC1808] in order to define a single, generic syntax for all URI.

And,

1.1 Overview of URI

URI are characterized by the following definitions:

  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.

Here are some in use:

1.3. Example URI

The following examples illustrate URI that are in common use.

ftp://ftp.is.co.za/rfc/rfc1808.txt -- ftp scheme for File Transfer Protocol services

gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles -- gopher scheme for Gopher and Gopher+ Protocol services

http://www.math.uio.no/faq/compression-faq/part1.html -- http scheme for Hypertext Transfer Protocol services

mailto:mduerst@ifi.unizh.ch -- mailto scheme for electronic mail addresses

news:comp.infosystems.www.servers.unix -- news scheme for USENET news groups and articles

telnet://melvyl.ucop.edu/ -- telnet scheme for interactive services via the TELNET Protocol

查看更多
该账号已被封号
3楼-- · 2019-03-11 04:47

A Uri object is usually used to tell a ContentProvider what we want to access by reference. It is an immutable one-to-one mapping to a resource or data. The method Uri.parse creates a new Uri object from a properly formated String. See here for more information about ContentProviders.

查看更多
聊天终结者
4楼-- · 2019-03-11 04:53

Uniform Resource Identifier (URI) is a string of characters used to identify a resource.A URI identifies a resource either by location, or a name, or both. Such identification enables interaction with representations of the resource over a network, typically the World Wide Web, using specific protocols. ex- a URL is a URI. * What is Uri.parse()* it does not 'parse'but it actually creates a Uri object, using the string passed to it and the string is hidden from the user. Now the question is what does the Uri object do?? So the URI object is an immutable reference to a URI which we can use to refer to resources .

查看更多
登录 后发表回答