Android涓?殑Intent璇︾粏璁茶В
聽聽聽聽聽鍦ㄤ竴涓狝ndroid搴旂敤涓?紝涓昏?鏄?敱鍥涚?缁勪欢缁勬垚鐨勶紝杩欏洓绉嶇粍浠跺彲鍙傝?冣?淎ndroid搴旂敤鐨勬瀯鎴愨?濄??br>
鑰岃繖鍥涚?缁勪欢鏄?嫭绔嬬殑锛屽畠浠?箣闂村彲浠ヤ簰鐩歌皟鐢?紝鍗忚皟宸ヤ綔锛屾渶缁堢粍鎴愪竴涓?湡姝g殑Android搴旂敤銆?br>
鍦ㄨ繖浜涚粍浠朵箣闂寸殑閫氳?涓?紝涓昏?鏄?敱Intent鍗忓姪瀹屾垚鐨勩??br>
聽聽聽聽聽Intent 璐熻矗瀵瑰簲鐢ㄤ腑涓?娆℃搷浣滅殑鍔ㄤ綔銆佸姩浣滄秹鍙婃暟鎹??侀檮鍔犳暟鎹?繘琛屾弿杩帮紝Android鍒欐牴鎹??Intent鐨勬弿杩帮紝璐熻矗鎵惧埌瀵瑰簲鐨勭粍浠讹紝灏?Intent浼犻?掔粰璋冪敤鐨勭粍浠讹紝骞跺畬鎴愮粍浠剁殑璋冪敤銆?br>
鍥犳?锛孖ntent鍦ㄨ繖閲岃捣鐫?涓?涓?獟浣撲腑浠嬬殑浣滅敤锛屼笓闂ㄦ彁渚涚粍浠朵簰鐩歌皟鐢ㄧ殑鐩稿叧淇℃伅锛屽疄鐜拌皟鐢ㄨ?呬笌琚?皟鐢ㄨ?呬箣闂寸殑瑙h?︺??br>
聽聽聽聽聽聽聽 渚嬪?锛屽湪涓?涓?仈绯讳汉缁存姢鐨勫簲鐢ㄤ腑锛屽綋鎴戜滑鍦ㄤ竴涓?仈绯讳汉鍒楄〃灞忓箷锛堝亣璁惧?搴旂殑Activity涓簂istActivity锛変笂锛岀偣鍑绘煇涓?仈绯讳汉鍚庯紝甯屾湜鑳藉?璺冲嚭姝よ仈绯讳汉鐨勮?缁嗕俊鎭?睆骞曪紙鍋囪?瀵瑰簲鐨凙ctivity涓篸etailActivity锛?br>
涓轰簡瀹炵幇杩欎釜鐩?殑锛宭istActivity 闇?瑕佹瀯閫犱竴涓?Intent锛岃繖涓狪ntent鐢ㄤ簬鍛婅瘔绯荤粺锛屾垜浠??鍋氣?滄煡鐪嬧?濆姩浣滐紝姝ゅ姩浣滃?搴旂殑鏌ョ湅瀵硅薄鏄??滄煇鑱旂郴浜衡?濓紝鐒跺悗璋冪敤startActivity (Intent intent)锛?br>
灏嗘瀯閫犵殑Intent浼犲叆锛岀郴缁熶細鏍规嵁姝?ntent涓?殑鎻忚堪锛屽埌ManiFest涓?壘鍒版弧瓒虫? Intent瑕佹眰鐨凙ctivity锛岀郴缁熶細璋冪敤鎵惧埌鐨凙ctivity锛屽嵆涓篸etailActivity锛屾渶缁堜紶鍏?Intent锛宒etailActivity鍒欎細鏍规嵁姝?ntent涓?殑鎻忚堪锛屾墽琛岀浉搴旂殑鎿嶄綔銆?br>
涓?銆佹娊璞℃弿杩拌?鎻忚堪浠?涔?br>聽聽聽聽聽聽聽 鍦ˋndroid鍙傝?冩枃妗d腑锛屽?Intent鐨勫畾涔夋槸鎵ц?鏌愭搷浣滅殑涓?涓?娊璞℃弿杩帮紙纭?疄寰堟娊璞★級銆傛垜浠?厛鏉ョ湅鐪嬭繖閲岀殑鎶借薄鎻忚堪锛屽埌搴曟弿杩颁簡浠?涔堛??br>聽聽聽聽聽聽聽 棣栧厛锛屾槸瑕佹墽琛岀殑鍔ㄤ綔锛坅ction锛夌殑涓?涓?畝瑕佹弿杩帮紝濡?VIEW_ACTION锛堟煡鐪嬶級銆丒DIT_ACTION锛堜慨鏀癸級绛夛紝Android涓烘垜浠?畾涔変簡涓?濂楁爣鍑嗗姩浣滐細
澶嶅埗鍐呭?鍒板壀璐存澘
浠g爜:
MAIN_ACTION
VIEW_ACTION
EDIT_ACTION
PICK_ACTION
GET_CONTENT_ACTION
DIAL_ACTION
CALL_ACTION
SENDTO_ACTION
ANSWER_ACTION
INSERT_ACTION
DELETE_ACTION
RUN_ACTION
LOGIN_ACTION
CLEAR_CREDENTIALS_ACTION
SYNC_ACTION
PICK_ACTIVITY_ACTION
WEB_SEARCH_ACTION
姝ゅ?锛屾垜浠?繕鍙?互鏍规嵁搴旂敤鐨勯渶瑕侊紝瀹氫箟鎴戜滑鑷?繁鐨勫姩浣滐紝骞跺彲瀹氫箟鐩稿簲鐨凙ctivity鏉ュ?鐞嗘垜浠?殑鑷?畾涔夊姩浣溿??br>
聽聽聽聽聽聽聽 鍏舵?锛屾槸鎵ц?鍔ㄤ綔瑕佹搷浣滅殑鏁版嵁锛坉ata锛夛紝Android涓?噰鐢ㄦ寚鍚戞暟鎹?殑涓?涓?URI鏉ヨ〃绀猴紝濡傚湪鑱旂郴浜哄簲鐢ㄤ腑锛屼竴涓?寚鍚戞煇鑱旂郴浜虹殑URI鍙?兘涓猴細content://contacts/1銆?br>
杩欑?URI琛ㄧず锛岄?氳繃 ContentURI杩欎釜绫绘潵鎻忚堪锛屽叿浣撳彲浠ュ弬鑰僡ndroid.net.ContentURI绫荤殑鏂囨。銆?br>
聽聽聽聽聽聽聽 浠ヨ仈绯讳汉搴旂敤涓轰緥锛屼互涓嬫槸涓?浜沘ction / data瀵癸紝鍙婂叾瀹冧滑瑕佽〃杈剧殑鎰忓浘锛?br>澶嶅埗鍐呭?鍒板壀璐存澘
浠g爜:
VIEW_ACTION content://contacts/1-- 鏄剧ず鏍囪瘑绗︿负"1"鐨勮仈绯讳汉鐨勮?缁嗕俊鎭?br>EDIT_ACTION content://contacts/1-- 缂栬緫鏍囪瘑绗︿负"1"鐨勮仈绯讳汉鐨勮?缁嗕俊鎭?br>VIEW_ACTION content://contacts/-- 鏄剧ず鎵?鏈夎仈绯讳汉鐨勫垪琛?br>PICK_ACTION content://contacts/-- 鏄剧ず鎵?鏈夎仈绯讳汉鐨勫垪琛?紝骞朵笖鍏佽?鐢ㄦ埛鍦ㄥ垪琛ㄤ腑閫夋嫨涓?涓?仈绯讳汉锛岀劧鍚庢妸杩欎釜鑱旂郴浜鸿繑鍥炵粰鐖禷ctivity銆備緥濡傦細鐢靛瓙閭?欢瀹㈡埛绔?彲浠ヤ娇鐢ㄨ繖涓?Intent锛岃?姹傜敤鎴峰湪鑱旂郴浜哄垪琛ㄤ腑閫夋嫨涓?涓?仈绯讳汉
聽聽聽聽聽聽聽 鍙﹀?锛岄櫎浜哸ction鍜宒ata杩欎袱涓?噸瑕佸睘鎬у?锛岃繕鏈変竴浜涢檮鍔犲睘鎬э細
category锛堢被鍒?級锛岃?鎵ц?鍔ㄤ綔鐨勯檮鍔犱俊鎭??備緥濡?LAUNCHER_CATEGORY 琛ㄧずIntent 鐨勬帴鍙楄?呭簲璇ュ湪Launcher涓?綔涓洪《绾у簲鐢ㄥ嚭鐜帮紱鑰孉LTERNATIVE_CATEGORY琛ㄧず褰撳墠鐨処ntent鏄?竴绯诲垪鐨勫彲閫夊姩浣滀腑鐨勪竴涓?紝杩欎簺鍔ㄤ綔鍙?互鍦ㄥ悓涓?鍧楁暟鎹?笂鎵ц?銆?br>
type锛堟暟鎹?被鍨嬶級锛屾樉寮忔寚瀹欼ntent鐨勬暟鎹?被鍨嬶紙MIME锛夈?備竴鑸琁ntent鐨勬暟鎹?被鍨嬭兘澶熸牴鎹?暟鎹?湰韬?繘琛屽垽瀹氾紝浣嗘槸閫氳繃璁剧疆杩欎釜灞炴?э紝鍙?互寮哄埗閲囩敤鏄惧紡鎸囧畾鐨勭被鍨嬭?屼笉鍐嶈繘琛屾帹瀵笺??br>
component锛堢粍浠讹級锛屾寚瀹欼ntent 鐨勭殑鐩?爣缁勪欢鐨勭被鍚嶇О銆傞?氬父 Android浼?action.EDIT_TITLE data=content://com.google.provider.NotePad/notes/{ID}}锛氭樉绀哄苟涓斿厑璁哥敤鎴风紪杈戞爣璇嗕负ID鐨勪究绗虹殑鏍囬?銆?/p>
聽
杞?嚜锛?a target="_blank" href="http://blog.csdn.net/dlmu2001/archive/2008/12/08/3478266.aspx">http://blog.csdn.net/dlmu2001/archive/2008/12/08/3478266.aspx
聽