❶ android中uri由哪三部分組成,簡述其意義
通用資源標志符(Universal Resource Identifier, 簡稱"URI")。
Uri代表要操作的數據,Android上可用的每種資源 - 圖像、視頻片段等都可以用Uri來表示。
URI一般由三部分組成:
在Android平台,URI主要分三個部分:scheme, authority and path。
其中authority又分為host和port。格式如下:scheme://host:port/path
舉個實際的例子:
content://com.example.project:200/folder/subfolder/etc
\---------/ \------------------ -/ \--/ \----------------------/
scheme host port path
\---------------------------/
authority
我們很經常需要解析Uri,並從Uri中獲取數據。
❷ android 中的uri到底是什麼
URI是統一資源標識符(Uniform Resource Identifier) 的意思,它的作用是根據這個URI找到某個資源文件,基本格式如: file:///sdcard/temp.jpg(就是根據你提供的例子生成的一個路徑)
ContentProvider是程序間共享數據的,它也需要生成URI供別的程序調用,格式如:
content:///StudentDB/student/name,以後你在別的程序想訪問另一個程序里的資料庫,就可以用這個URI去訪問了,而不用進行資料庫連接的操作,非常方便
URL顯得很宏觀,是網路資源定位的,而URI是應用程序內部或之間定位
❸ android中Uri.parse()用法是什麼
調web瀏覽器
Uri myBlogUri = Uri.parse("http://xxxxx.com");
returnIt = new Intent(Intent.ACTION_VIEW, myBlogUri);
地圖
Uri mapUri = Uri.parse("geo:38.899533,-77.036476");
returnIt = new Intent(Intent.ACTION_VIEW, mapUri);
調撥打電話界面
Uri telUri = Uri.parse("tel:100861");
returnIt = new Intent(Intent.ACTION_DIAL, telUri);
直接撥打電話
Uri callUri = Uri.parse("tel:100861");
returnIt = new Intent(Intent.ACTION_CALL, callUri);
卸載
Uri uninstallUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);
安裝
Uri installUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
播放
Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3");
returnIt = new Intent(Intent.ACTION_VIEW, playUri);
調用發郵件
Uri emailUri = Uri.parse("mailto:[email protected]");
returnIt = new Intent(Intent.ACTION_SENDTO, emailUri);
發郵件
returnIt = new Intent(Intent.ACTION_SEND);
String[] tos = { "[email protected]" };
String[] ccs = { "[email protected]" };
returnIt.putExtra(Intent.EXTRA_EMAIL, tos);
returnIt.putExtra(Intent.EXTRA_CC, ccs);
returnIt.putExtra(Intent.EXTRA_TEXT, "body");
returnIt.putExtra(Intent.EXTRA_SUBJECT, "subject");
returnIt.setType("message/rfc882");
Intent.createChooser(returnIt, "Choose Email Client");
發簡訊
Uri smsUri = Uri.parse("tel:100861");
returnIt = new Intent(Intent.ACTION_VIEW, smsUri);
returnIt.putExtra("sms_body", "yyyy");
returnIt.setType("vnd.android-dir/mms-sms")
直接發郵件
Uri smsToUri = Uri.parse("smsto://100861");
returnIt = new Intent(Intent.ACTION_SENDTO, smsToUri);
returnIt.putExtra("sms_body", "yyyy");
發彩信
Uri mmsUri = Uri.parse("content://media/external/images/media/23");
returnIt = new Intent(Intent.ACTION_SEND);
returnIt.putExtra("sms_body", "yyyy");
returnIt.putExtra(Intent.EXTRA_STREAM, mmsUri);
returnIt.setType("image/png");
❹ URI是什麼,在Android中有什麼作用
通用資源標志符(Universal Resource Identifier, 簡稱"URI")。
Uri代表要操作的數據,Android上可用的每種資源 - 圖像、視頻片段等都可以用Uri來表示。
URI一般由三部分組成:
在Android平台,URI主要分三個部分:scheme, authority and path。
其中authority又分為host和port。格式如下:scheme://host:port/path
舉個實際的例子:
content://com.example.project:200/folder/subfolder/etc
\---------/ \------------------ -/ \--/ \----------------------/
scheme host port path
\---------------------------/
authority
我們很經常需要解析Uri,並從Uri中獲取數據。
Android系統提供了兩個用於操作Uri的工具類,分別為UriMatcher 和ContentUris 。
掌握它們的使用,會便於我們的Android開發工作。
❺ android 7.0 調用相機FileProvider生成的URI,作為相機開發的接收者,怎麼使用URI
android 7.0以上, 禁止使用Uri中包含一個文件的絕對路徑, 必須要使用content方式傳遞文件路徑
❻ android uri是什麼
URI:資源標志符(Uniform Resource Identifier, 簡稱"URI")。
用來標識你的文件、資料庫、數據信息等的位置。
❼ android中文件uri和url的區別
URL是uniform resource locator,統一資源定位器,它是一種具體的URI,即URL可以用來標識一個資源,而且還指明了如何locate這個資源。而URN,uniform resource name,統一資源命名,是通過名字來標識資源,比如mailto:java[email protected]。也就是說,URI是以一種抽象的,高層次概念定義統一資源標識,而URL和URN則是具體的資源標識的方式。URL和URN都是一種URI。
❽ android中Uri.parse()用法
通用資源標志符(Universal Resource Identifier, 簡稱"URI")。
Uri代表要操作的數據,Android上可用的每種資源 - 圖像、視頻片段等都可以用Uri來表示。Android平台而言,URI主要分三個部分:
scheme
authority
path
其中authority又分為host和port。格式如下:
scheme://host:port/path
實際的例子:
我們很經常需要解析Uri,並從Uri中獲取數據。
Android系統提供了兩個用於操作Uri的工具類,分別為UriMatcher 和ContentUris 。
掌握它們的使用,會便於我們的Android開發工作。
❾ Android 兩個Activity之間怎樣使用Uri傳遞圖片,怎樣獲取圖片的Uri,怎樣通過Uri得到圖片
Activity之間傳遞數據是通過Intent來傳遞的。
Intent是一種運行時綁定(run-time binding)機制,它能在程序運行過程中連接兩個不同的組件。通過Intent,你的程序可以向Android表達某種請求或者意願,Android會根據意願的內容選擇適當的組件來完成請求。比如,有一個Activity希望打開網頁瀏覽器查看某一網頁的內容,那麼這個Activity只需要發出WEB_SEARCH_ACTION給Android,Android就會根據Intent的請求內容,查詢各組件注冊時聲明的IntentFilter,找到網頁瀏覽器的Activity來瀏覽網頁。
Android的三個基本組件——Activity,Service和Broadcast Receiver——都是通過Intent機制激活的,不同類型的組件有不同的傳遞Intent方式:
要激活一個新的Activity,或者讓一個現有的Activity做新的操作,可以通過調用Context.startActivity()或者Activity.startActivityForResult()方法。
要啟動一個新的Service,或者向一個已有的Service傳遞新的指令,調用Context.startService()方法或者調用Context.bindService()方法將調用此方法的上下文對象與Service綁定。
Context.sendBroadcast()、Context.sendOrderBroadcast()、Context.sendStickBroadcast()這三個方法可以發送Broadcast Intent。發送之後,所有已注冊的並且擁有與之相匹配IntentFilter的BroadcastReceiver就會被激活。
Intent一旦發出,Android都會准確找到相匹配的一個或多個Activity,Service或者BroadcastReceiver作響應。所以,不同類型的Intent消息不會出現重疊,即Broadcast的Intent消息只會發送給BroadcastReceiver,而決不會發送給Activity或者Service。由startActivity()傳遞的消息也只會發給Activity,由startService()傳遞的Intent只會發送給Service。