2013-07-04 54 views
13

Chức năng của Uri là gì và cách sử dụng Uri.parse()?Uri.parse là gì trong android

Ví dụ:

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

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

telgeo tham khảo?

+1

http://developer.android.com/reference/android/net/Uri.html#parse(java.lang.String). kiểm tra các tài liệu – Raghunandan

+0

Theo hiểu biết của tôi, chúng là các giao thức giống như 'http' – Aswin

Trả lời

9

Đối tượng Uri thường được sử dụng để thông báo cho một số ContentProvider những gì chúng tôi muốn truy cập bằng cách tham chiếu. Nó là một ánh xạ một-một-bất biến đối với một tài nguyên hoặc dữ liệu. Phương thức Uri.parse tạo đối tượng Uri mới từ một số được định dạng phù hợp String. Xem here để biết thêm thông tin về ContentProviders.

6

Trong trường hợp bạn muốn câu trả lời cụ thể về bản chất của uriString đó là một cuộc tranh cãi ở đây,
Từ,
http://developer.android.com/reference/android/net/Uri.html#parse%28java.lang.String%29

Bất biến tham chiếu URI. Tham chiếu URI bao gồm một URI và một đoạn , thành phần của URI theo sau '#'. Xây dựng và phân tích tham chiếu URI mà phù hợp với RFC 2396.

Và Về RFC tiêu chuẩn 2396,
Từ,
http://www.faqs.org/rfcs/rfc2396.html

Tài liệu này cập nhật và kết hợp "Uniform Resource Locators"
[RFC1738] và "Bộ định vị tài nguyên đồng nhất tương đối" [RFC1808] theo thứ tự để xác định cú pháp chung, duy nhất cho tất cả URI.

Và,

1,1 Tổng quan về URI

URI được đặc trưng bởi các định nghĩa sau đây:

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. 

Dưới đây là một số trong sử dụng:

1.3. Ví dụ URI

Ví dụ sau minh họa URI đang được sử dụng phổ biến.

ftp://ftp.is.co.za/rfc/rfc1808.txt - chương trình ftp cho các dịch vụ File Transfer Protocol

gopher: //spinaltap.micro.umn.edu/00/Thời tiết/California/Los% 20Angeles - chương trình gopher cho các dịch vụ Gopher và Gopher + Nghị định thư

http://www.math.uio.no/faq/compression-faq/part1.html - http chương trình cho các dịch vụ Hypertext Transfer Protocol

mailto: [email protected] - mailto chương trình cho thư điện tử địa chỉ

tin tức: comp.infosystems.www.servers.unix - chương trình tin tức cho các nhóm tin tức Usenet và điều

telnet: //melvyl.ucop.edu/ - sơ đồ telnet cho các dịch vụ tương tác thông qua Giao thức TELNET

1

Mã định danh tài nguyên đồng nhất (URI) là một chuỗi ký tự được sử dụng để xác định tài nguyên.URI xác định tài nguyên theo vị trí hoặc tên hoặc cả hai . Nhận dạng như vậy cho phép tương tác với các đại diện của tài nguyên qua mạng, thường là World Wide Web, sử dụng các giao thức cụ thể. ví dụ: URL là một URI. * Uri.parse() * nó không 'parse'but nó thực sự tạo ra một đối tượng Uri, sử dụng chuỗi được truyền cho nó và chuỗi bị ẩn khỏi người dùng. Bây giờ câu hỏi là đối tượng Uri làm gì? Vì vậy, đối tượng URI là một tham chiếu bất biến đối với một URI mà chúng ta có thể sử dụng để tham chiếu đến tài nguyên.

Các vấn đề liên quan