锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
]]>
<package name="com.android.setupwizard" codePath="/system/app/SetupWizard.apk" nativeLibraryPath="/data/data/com.android.setupwizard/lib" flags="1" ft="13349457a90" it="13349457a90" ut="13349457a90" version="130" userId="10016">
<sigs count="1">
<cert index="0" />
</sigs>
<disabled-components>
<item name="com.android.setupwizard.SetupWizardActivity" />
</disabled-components>
</package>
鐜板湪闇瑕佸湪榪愯鏃剁鐢ㄦ煇涓獁idget錛屽悓鏃舵湁涓涓猻ystem property鐢ㄦ潵鏍囪瘑鏄惁闇瑕佺鐢ㄣ?br />鍥犱負widget瀹為檯涓婂氨鏄釜reveiver錛屽畠鎺ユ敹android.appwidget.action.APPWIDGET_UPDATE鐨刟ction錛屾墍浠ュ紑濮嬬殑鎬濊礬鏄細
鍒涘緩涓涓狟roadcastReceiver錛屾帴鏀禝ntent.ACTION_BOOT_COMPLETED榪欎釜鍔ㄤ綔錛屼粠鑰屽湪鍚姩瀹屾垚鍚庤皟鐢⊿ystemProperties.get("disable_widget")錛屽鏋滈渶瑕佺鐢ㄨ繖涓獁idget錛岄偅涔堣皟鐢細
PackageManager.setComponentEnabledSetting(widgetComponentName錛孭ackageManager.COMPONENT_ENABLED_STATE_ENABLED,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 PackageManager.DONT_KILL_APP);
浣嗘槸闂鏄紝璋冪敤榪欎釜鏂規硶disable鎺夎繖涓獁idget鍚庯紝鍙戠幇蹇呴』鎶婅澶囬噸鍚箣鍚庢墠鑳界敓鏁?..
緇忚繃google錛屽彂鐜伴棶棰樺嚭鍦╟om.android.server.AppWidgetService.java銆?br />鍘熸潵寮鏈哄悗錛孲ystemServer浼氳皟鐢ˋppWidgetService鐨剆ystemReady()鏂規硶錛岃繖涓柟娉曢氳繃PackageManager鏌ヨ鎵鏈夌殑widget receiver緇勪歡錛屼繚瀛樺埌mInstalledProviders鍙橀噺鍒楄〃涓紝騫舵寔涔呭寲widget淇℃伅鍒?data/system/appwidgets.xml涓?br />鑰屽湪Launcher涓婇暱鎸夋坊鍔爓idget鏃剁殑閭d釜widget鍒楄〃淇℃伅涔熸槸閫氳繃AppWidgetService鍙栧緱mInstalledProviders鍒楄〃銆?br />闂鍦ㄤ簬鎴戜滑閫氳繃PackageManager.setComponentEnabledSetting錛堬級紱佺敤鎺夋煇涓獁idget鍚庯紝packagemanager紜疄灝嗚繖涓粍浠禿isable浜嗭紝浣嗘槸AppWidgetService鍗存病鏈夊幓浠巔ackagemanager reload widget淇℃伅錛岃繖灝卞鑷翠簡mInstalledProviders涓繚瀛樼殑widget淇℃伅榪樻槸寮鏈烘椂load榪涙潵鐨勯偅浜涗俊鎭紝騫舵病鏈変笌pm榪涜鍚屾銆傜洿鍒頒笅涓嬈″紑鏈鴻皟鐢╯ystemReady閲嶆柊鍔犺澆widget淇℃伅鎵嶄細鍒鋒柊榪欎釜鍒楄〃銆?br />
鍙傝冿細
Dynamically enabling or disabling a widget with PackageManager.setComponentEnabledSetting does not work
http://code.google.com/p/android/issues/detail?id=6533
http://blog.csdn.net/yinlijun2004/article/details/6136108
]]>
聽2聽{
聽3聽聽聽聽聽int聽ret聽=聽-EBADF;
聽4聽聽聽聽聽struct聽file聽*聽file聽=聽fget(fildes);
聽5聽
聽6聽聽聽聽聽if聽(file)
聽7聽聽聽聽聽聽聽聽聽ret聽=聽dupfd(file,聽0);
聽8聽聽聽聽聽return聽ret;
聽9聽}
10聽
鑰宻ys_dup()鐨勪富浣撴槸dupfd()錛堝畾涔夊湪鍚屼竴涓枃浠朵腑錛夛細
聽2聽{
聽3聽聽聽聽聽struct聽files_struct聽*聽files聽=聽current->files;
聽4聽聽聽聽聽int聽ret;
聽5聽
聽6聽聽聽聽聽ret聽=聽locate_fd(files,聽file,聽start);
聽7聽聽聽聽聽if聽(ret聽<聽0)
聽8聽聽聽聽聽聽聽聽聽goto聽out_putf;
聽9聽聽聽聽聽allocate_fd(files,聽file,聽ret);
10聽聽聽聽聽return聽ret;
11聽
12聽out_putf:
13聽聽聽聽聽write_unlock(&files->file_lock);
14聽聽聽聽聽fput(file);
15聽聽聽聽聽return聽ret;
16聽}
17聽
娉細dup鍜宒up2鐨勫師鍨嬪涓嬶細
#include <unistd.h>
int dup(int file_descriptor);
int dup2(int file_descriptor1, int file_descriptor2)
dup榪斿洖鐨勬枃浠舵弿榪扮鎬繪槸鍙栨渶灝忕殑鍙敤鍊?br />dup2榪斿洖鐨勬枃浠舵弿榪扮鎴栬呬笌file_descriptor2鐩稿悓錛屾垨鑰呮槸絎竴涓ぇ浜庤鍙傛暟鐨勫彲鐢ㄥ箋?/font>
聽聽聽 鑰岃繖涔堜竴涓畝鍗曠殑緋葷粺璋冪敤鏄浣曞畬鎴愰噸瀹氬悜榪欎釜鑹板法鐨勪換鍔$殑鍛紵鎴戜滑涓嶅Θ鍏堢湅涓緥瀛愩?br />聽聽聽
褰撴垜浠湪shell涓嬭緭鍏ュ涓嬪懡浠わ細鈥渆cho
hello!鈥濓紝榪欐潯鍛戒護瑕佹眰shell榪涚▼鎵ц涓涓彲鎵ц鏂囦歡echo錛屽弬鏁頒負鈥渉ello!鈥濄傚綋shell鎺ユ敹鍒板懡浠や箣鍚庯紝鍏堟壘鍒?
bin/echo錛岀劧鍚巉ork()鍑轟竴涓瓙榪涚▼璁╀粬鎵цbin/echo錛屽茍灝嗗弬鏁頒紶閫掔粰瀹冿紝鑰岃繖涓繘紼嬩粠shell緇ф壙浜嗕笁涓爣鍑嗘枃浠訛紝鍗蟲爣鍑嗚緭鍏?
錛坰tdin錛夛紝鏍囧噯杈撳嚭錛坰tdout錛夊拰鏍囧噯鍑洪敊淇℃伅錛坰tderr錛夛紝浠栦滑涓変釜鐨勬枃浠跺彿鍒嗗埆涓?銆?銆?銆?/font>鑰岃嚦浜巈cho榪涚▼鐨勫伐浣滃緢綆鍗曪紝灝辨槸灝嗗弬鏁扳渉ello!鈥濆啓鍒版爣鍑嗚緭鍑烘枃浠朵腑鍘伙紝閫氬父閮芥槸鎴戜滑鐨勬樉紺哄櫒涓娿備絾鏄鏋滄垜浠皢鍛戒護鏀規垚鈥渆cho hello! >
foo鈥濓紝鍒欏湪鎵ц鏃惰緭鍑哄皢浼氳閲嶅畾鍚戝埌紓佺洏鏂囦歡foo涓?font color="#0000FF">錛堟敞錛氶噸瀹氬悜浜庢枃浠舵弿榪扮鏈夊叧錛?/font>銆傛垜浠亣瀹氬湪姝や箣鍓嶈shell榪涚▼鍙湁涓変釜鏍囧噯鏂囦歡鎵撳紑錛屾枃浠跺彿鍒嗗埆涓?銆?銆?錛屼互涓婂懡浠よ灝嗘寜濡備笅搴忓垪鎵ц錛?br />聽聽聽 (1) 鎵撳紑鎴栧垱寤虹鐩樻枃浠秄oo錛屽鏋渇oo涓師鏉ユ湁鍐呭錛屽垯娓呴櫎鍘熸潵鍐呭錛屽叾鏂囦歡鍙蜂負3銆?br />聽聽聽 (2) 閫氳繃dup()澶嶅埗鏂囦歡stdout錛屽嵆灝嗘枃浠跺彿1鍑虹殑file緇撴瀯鎸囬拡澶嶅埗鍒版枃浠跺彿4澶勶紝鐩殑鏄皢stdout鐨刦ile鎸囬拡鏆傛椂淇濆瓨涓涓?br />聽聽聽 (3) 鍏抽棴stdout錛屽嵆1鍙鋒枃浠訛紝浣嗘槸鐢變簬4鍙鋒枃浠跺stdout涔熷悓鏃舵湁涓紩鐢紝鎵浠tdout鏂囦歡騫舵湭鐪熸鍏抽棴錛屽彧鏄吘鍑?鍙鋒枃浠跺彿浣嶇疆銆?br />聽聽聽 (4) 閫氳繃dup()錛屽鍒?鍙鋒枃浠訛紙鍗崇鐩樻枃浠秄oo錛夛紝鐢變簬1鍙鋒枃浠跺叧闂紝鍏朵綅緗┖緙猴紝鏁?鍙鋒枃浠惰澶嶅埗鍒?鍙鳳紝鍗寵繘紼嬩腑鍘熸潵鎸囧悜stdout鐨勬寚閽堟寚鍚戜簡foo銆?br />聽聽聽
(5)
閫氳繃緋葷粺璋冪敤fork()鍜宔xec()鍒涘緩瀛愯繘紼嬪茍鎵цecho錛屽瓙榪涚▼鍦ㄦ墽琛宔cho鍓嶅鍏抽棴3鍙峰拰4鍙鋒枃浠訛紝鍙暀涓?銆?銆?涓変釜鏂囦歡錛岃娉ㄦ剰錛岃繖
鏃剁殑1鍙鋒枃浠跺凡緇忎笉鏄痵tdout鑰屾槸紓佺洏鏂囦歡foo浜嗐傚綋echo鎯沖悜stdout鏂囦歡鍐欏叆鈥渉ello!鈥濇椂鑷劧灝卞啓鍏ュ埌浜唂oo涓?br />聽聽聽 (6) 鍥炲埌shell鍚庯紝鍏抽棴鎸囧悜foo鐨?鍙蜂笌3鍙鋒枃浠舵枃浠訛紝鍐嶇敤dup()鍜宑lose()灝?鍙鋒仮澶嶈嚦stdout錛岃繖鏍穝hell灝辨仮澶嶄簡0銆?銆?涓変釜鏍囧噯杈撳叆/杈撳嚭鏂囦歡銆?br />
聽聽聽
鐢辨鍙錛?font color="#FF0000">褰揺cho紼嬪簭錛堟垨鍏朵粬錛夊湪榪愯鐨勬椂鍊欏茍涓嶇煡閬搒tdout錛堝浜巗tdin鍜宻tderr鍚屾牱錛夋寚鍚戜粈涔堬紝榪涚▼涓庡疄闄呰緭鍑烘枃浠舵垨璁懼鐨勭粨鍚堟槸鍦ㄨ繍琛屾椂鐢卞叾鐖惰繘紼嬧滃寘鍔炩濈殑銆傝繖鏍峰氨綆鍖栦簡瀛愯繘紼嬬殑紼嬪簭璁捐錛屽洜涓哄湪璁捐鏃跺彧瑕佽窡涓変釜閫昏緫涓婂瓨鍦ㄧ殑鏂囦歡鎵撲氦閬撳氨鍙互浜?/font>銆傚彲鑳芥湁浜轟細瑙夊緱榪欏緢鍍忛潰鍚戝璞′腑
鐨勫鎬佸拰閲嶈澆錛屾病鏈変粈涔堟柊濂囦箣澶勶紝浣嗘槸濡傛灉浣犳椿鍦?0鐢氳嚦40騫村墠錛屽彲鑳戒綘浼氭敼鍙樹綘鐨勭湅娉曘偮?
]]>
Activity鐨勭敓鍛藉懆鏈熼噷騫舵病鏈夋彁鍒皁nSaveInstanceState鐨勮Е鍙戯紝榪欎釜鍑芥暟鎻愪緵浜嗕負鎴戜滑鍦ㄦ煇浜涙儏鍐典笅淇濆瓨Activity淇℃伅鐨勬満浼氾紝浣嗛渶瑕佹敞鎰忕殑鏄繖涓嚱鏁頒笉鏄粈涔堟椂鍊欓兘浼氳璋冪敤鐨勶紝瀹樻柟鏂囨。瑙i噴鐨勬瘮杈冩竻妤氾紝鐗規
緲昏瘧涓涓嬨?
鍘熸枃鍑哄錛歛ndroid-sdk-windows-1.5_r3/docs/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle)
protected void onSaveInstanceState (Bundle outState)
聽聽聽聽聽聽 Called to retrieve per-instance state from an activity before
being killed so that the state can be restored in onCreate(Bundle) or
onRestoreInstanceState(Bundle) (the Bundle populated by this method will
be passed to both). This method is called before an activity may be
killed so that when it comes back some time in the future it can restore
its state. For example, if activity B is launched in front of activity
A, and at some point activity A is killed to reclaim resources, activity
A will have a chance to save the current state of its user interface
via this method so that when the user returns to activity A, the state
of the user interface can be restored via onCreate(Bundle) or
onRestoreInstanceState(Bundle).
聽聽聽
鍦╝ctivity琚潃鎺変箣鍓嶈皟鐢ㄤ繚瀛樻瘡涓疄渚嬬殑鐘舵?浠ヤ繚璇佽鐘舵佸彲浠ュ湪onCreate(Bundle)鎴栬?
onRestoreInstanceState(Bundle)
(浼犲叆鐨凚undle鍙傛暟鏄敱onSaveInstanceState灝佽濂界殑)涓仮澶嶃傝繖涓柟娉曞湪涓涓猘ctivity琚潃姝誨墠璋冪敤錛屽綋璇?
activity鍦ㄥ皢鏉ユ煇涓椂鍒誨洖鏉ユ椂鍙互鎭㈠鍏跺厛鍓嶇姸鎬併備緥濡傦紝濡傛灉activity B鍚敤鍚庝綅浜巃ctivity
A鐨勫墠绔紝鍦ㄦ煇涓椂鍒籥ctivity
A鍥犱負緋葷粺鍥炴敹璧勬簮鐨勯棶棰樿琚潃鎺夛紝A閫氳繃onSaveInstanceState灝嗘湁鏈轟細淇濆瓨鍏剁敤鎴風晫闈㈢姸鎬侊紝浣垮緱灝嗘潵鐢ㄦ埛榪斿洖鍒癮ctivity
A鏃惰兘閫氳繃onCreate(Bundle)鎴栬卭nRestoreInstanceState(Bundle)鎭㈠鐣岄潰鐨勭姸鎬併?
聽聽聽 Do not confuse this method with activity lifecycle callbacks
such as onPause(), which is always called when an activity is being
placed in the background or on its way to destruction, or onStop() which
is called before destruction. One example of when onPause() and
onStop() is called and not this method is when a user navigates back
from activity B to activity A: there is no need to call
onSaveInstanceState(Bundle) on B because that particular instance will
never be restored, so the system avoids calling it. An example when
onPause() is called and not onSaveInstanceState(Bundle) is when activity
B is launched in front of activity A: the system may avoid calling
onSaveInstanceState(Bundle) on activity A if it isn't killed during the
lifetime of B since the state of the user interface of A will stay
intact.
聽聽
聽聽聽
涓嶈灝嗚繖涓柟娉曞拰activity鐢熷懡鍛ㄦ湡鍥炶皟濡俹nPause()鎴杘nStop()鎼炴販娣嗕簡錛宱nPause()鍦╝ctivtiy琚斁緗埌鑳屾櫙鎴栬?
鑷閿姣佹椂鎬諱細琚皟鐢紝onStop()鍦╝ctivity琚攢姣佹椂琚皟鐢ㄣ備竴涓細璋冪敤onPause()鍜宱nStop()錛屼絾涓嶈Е鍙?
onSaveInstanceState鐨勪緥瀛愭槸褰撶敤鎴蜂粠activity B榪斿洖鍒癮ctivity
A鏃訛細娌℃湁蹇呰璋冪敤B鐨刼nSaveInstanceState(Bundle)錛屾鏃剁殑B瀹炰緥姘歌繙涓嶄細琚仮澶嶏紝鍥犳緋葷粺浼氶伩鍏嶈皟鐢ㄥ畠銆備竴涓皟鐢?
onPause()浣嗕笉璋冪敤onSaveInstanceState鐨勪緥瀛愭槸褰揳ctivity B鍚姩騫跺鍦╝ctivity
A鐨勫墠绔細濡傛灉鍦˙鐨勬暣涓敓鍛藉懆鏈熼噷A鐨勭敤鎴風晫闈㈢姸鎬侀兘娌℃湁琚牬鍧忕殑璇濓紝緋葷粺鏄笉浼氳皟鐢╝ctivity
A鐨刼nSaveInstanceState(Bundle)鐨勩?
聽聽聽 The default implementation takes care of most of the UI
per-instance state for you by calling onSaveInstanceState() on each view
in the hierarchy that has an id, and by saving the id of the currently
focused view (all of which is restored by the default implementation of
onRestoreInstanceState(Bundle)). If you override this method to save
additional information not captured by each individual view, you will
likely want to call through to the default implementation, otherwise be
prepared to save all of the state of each view yourself. If called, this
method will occur before onStop(). There are no guarantees about
whether it will occur before or after onPause().
聽聽聽聽聽
榛樿鐨勫疄鐜拌礋璐d簡澶ч儴鍒哢I瀹炰緥鐘舵?鐨勪繚瀛?錛岄噰鐢ㄧ殑鏂瑰紡鏄皟鐢║I灞備笂姣忎釜鎷ユ湁id鐨剉iew鐨刼nSaveInstanceState()
錛屽茍涓斾繚瀛樺綋鍓嶈幏寰楃劍鐐圭殑view鐨刬d(鎵鏈変繚瀛樼殑鐘舵佷俊鎭兘浼氬湪榛樿鐨刼nRestoreInstanceState(Bundle)瀹炵幇涓仮澶?銆?
濡傛灉浣犺鍐欒繖涓柟娉曟潵淇濆瓨棰濆鐨勬病鏈夎鍚勪釜view淇濆瓨鐨勪俊鎭紝浣犲彲鑳芥兂瑕佸湪榛樿瀹炵幇榪囩▼涓皟鐢ㄦ垨鑰呰嚜宸變繚瀛樻瘡涓鍥劇殑鎵鏈夌姸鎬併傚鏋滆璋冪敤錛岃繖涓柟娉曚細
鍦╫nStop()鍓嶈瑙﹀彂錛屼絾緋葷粺騫朵笉淇濊瘉鏄惁鍦╫nPause()涔嬪墠鎴栬呬箣鍚庤Е鍙戙?
寰堝涓嶆槑鐧紸ctivity綾諱腑鍖呭惈鐨刼nSaveInstanceState鍜宱nRestoreInstanceState鏈変粈涔堢敤錛岄鍏堝0
鏄庝笅浣跨敤榪欎袱涓柟娉曟椂涓瀹氳娉ㄦ剰鎯呭喌鍜屼簡瑙ctivity鐨勭敓鍛藉懆鏈燂紝鍚﹀垯鏈夌殑鏃跺櫬?
onSaveInstanceState鍜宱nRestoreInstanceState
鍙兘涓嶄細琚Е鍙戯紝铏界劧浠栦滑閮芥槸Activity鐨勯噸鍐欐柟娉曘傦紙鏂?Android寮鍙戠綉錛?
浠栦滑姣旇緝甯哥敤鍒扮殑鍦版柟鏄?
Sensor銆丩and鍜孭ort甯冨眬鐨勮嚜鍔ㄥ垏鎹紝榪囧幓Android寮鍙戠綉鏇劇粡璇磋繃瑙e喅妯睆鍜岀珫灞忓垏鎹㈠甫鏉ョ殑鏁版嵁琚疆絀烘垨鑰呰onCreate琚噸澶嶈皟
鐢ㄩ棶棰橈紝鍏跺疄Android鎻愪緵鐨刼nSaveInstanceState鏂規硶鍙互淇濆瓨褰撳墠鐨勭獥鍙g姸鎬佸湪鍗沖皢甯冨眬鍒囨崲鍓嶆垨褰撳墠Activity琚帹鍏ュ巻鍙?
鏍堬紝鍏跺疄甯冨眬鍒囨崲涔熻皟鐢ㄨ繃onPause鎵浠ヨ鎺ㄥ叆Activity鐨刪istory
stack錛屽鏋滄垜浠殑Activity鍦ㄥ悗鍙版病鏈夊洜涓鴻繍琛屽唴瀛樺悆绱ц娓呯悊錛屽垯鍒囨崲鍥炴椂浼氳Е鍙憃nRestoreInstanceState鏂規硶銆?
榪欎袱涓柟娉曚腑鍙傛暟鍧囦負Bundle錛屽彲浠ュ瓨鏀劇被浼?SharedPreferences 鐨勬暟鎹紝鎵浠ヤ嬌鐢ㄥ畠浠綔涓哄綋鍓嶇獥鍙g殑鐘舵佷繚瀛樻槸姣旇緝鍚堥傜殑銆傚疄闄呬嬌鐢ㄤ唬鐮?
@Override
聽 protected void onSaveInstanceState(Bundle outState){
聽聽聽聽聽聽聽聽聽聽聽 outState.putString("lastPath", "/sdcard/android123/cwj/test");
聽 }
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
String cwjString = savedInstanceState.getString("lastPath");
}
onSaveInstanceState鍜宱nRestoreInstanceState瑙﹀彂鐨勬椂鏈?
宸叉湁 199 嬈¢槄璇?2011-3-10 10:32 |涓漢鍒嗙被:Android|鍏抽敭璇?onSaveInstanceState onRestoreInstanceState
鍏堢湅Application Fundamentals涓婄殑涓孌佃瘽錛?
Android calls onSaveInstanceState() before the activity becomes
vulnerable to being destroyed by the system, but does not bother calling
it when the instance is actually being destroyed by a user action (such
as pressing the BACK key)
浠庤繖鍙ヨ瘽鍙互鐭ラ亾錛屽綋鏌愪釜activity鍙樺緱鈥滃鏄撯濊緋葷粺閿姣佹椂錛岃activity鐨刼nSaveInstanceState灝變細琚墽琛岋紝闄ら潪璇ctivity鏄鐢ㄦ埛涓誨姩閿姣佺殑錛屼緥濡傚綋鐢ㄦ埛鎸塀ACK閿殑鏃跺欍?
娉ㄦ剰涓婇潰鐨勫弻寮曞彿錛屼綍涓衡滃鏄撯濓紵璦涓嬩箣鎰忓氨鏄activity榪樻病鏈夎閿姣侊紝鑰屼粎浠呮槸涓縐嶅彲鑳芥с傝繖縐嶅彲鑳芥ф湁鍝簺錛熼氳繃閲嶅啓涓涓?
activity鐨勬墍鏈夌敓鍛藉懆鏈熺殑onXXX鏂規硶錛屽寘鎷琽nSaveInstanceState鍜宱nRestoreInstanceState鏂規硶錛屾垜
浠彲浠ユ竻妤氬湴鐭ラ亾褰撴煇涓猘ctivity錛堝亣瀹氫負activity
A錛夋樉紺哄湪褰撳墠task鐨勬渶涓婂眰鏃訛紝鍏秓nSaveInstanceState鏂規硶浼氬湪浠涔堟椂鍊欒鎵ц錛屾湁榪欎箞鍑犵鎯呭喌錛?
1銆佸綋鐢ㄦ埛鎸変笅HOME閿椂銆傝繖鏄樉鑰屾槗瑙佺殑錛岀郴緇熶笉鐭ラ亾浣犳寜涓婬OME鍚庤榪愯澶氬皯鍏朵粬鐨勭▼搴忥紝鑷劧涔熶笉鐭ラ亾activity A鏄惁浼氳閿姣侊紝鏁呯郴緇熶細璋冪敤onSaveInstanceState錛岃鐢ㄦ埛鏈夋満浼氫繚瀛樻煇浜涢潪姘鎬箙鎬х殑鏁版嵁銆備互涓嬪嚑縐嶆儏鍐電殑鍒嗘瀽閮介伒寰鍘熷垯
2銆侀暱鎸塇OME閿紝閫夋嫨榪愯鍏朵粬鐨勭▼搴忔椂銆?
3銆佹寜涓嬬數婧愭寜閿紙鍏抽棴灞忓箷鏄劇ず錛夋椂銆?
4銆佷粠activity A涓惎鍔ㄤ竴涓柊鐨刟ctivity鏃躲?
5銆佸睆騫曟柟鍚戝垏鎹㈡椂錛屼緥濡備粠绔栧睆鍒囨崲鍒版í灞忔椂銆傚湪灞忓箷鍒囨崲涔嬪墠錛岀郴緇熶細閿姣乤ctivity A錛屽湪灞忓箷鍒囨崲涔嬪悗緋葷粺鍙堜細鑷姩鍦板垱寤篴ctivity A錛屾墍浠nSaveInstanceState涓瀹氫細琚墽琛?
鎬昏岃█涔嬶紝onSaveInstanceState鐨勮皟鐢ㄩ伒寰竴涓噸瑕佸師鍒欙紝鍗沖綋緋葷粺鈥滄湭緇忎綘璁稿彲鈥濇椂閿姣佷簡浣犵殑activity錛屽垯
onSaveInstanceState浼氳緋葷粺璋冪敤錛岃繖鏄郴緇熺殑璐d換錛屽洜涓哄畠蹇呴』瑕佹彁渚涗竴涓満浼氳浣犱繚瀛樹綘鐨勬暟鎹紙褰撶劧浣犱笉淇濆瓨閭e氨闅忎究浣犱簡錛夈?
鑷充簬onRestoreInstanceState鏂規硶錛岄渶瑕佹敞鎰忕殑鏄紝onSaveInstanceState鏂規硶鍜?
onRestoreInstanceState鏂規硶鈥滀笉涓瀹氣濇槸鎴愬鐨勮璋冪敤鐨勶紝onRestoreInstanceState琚皟鐢ㄧ殑鍓嶆彁
鏄紝activity A鈥滅‘瀹炩濊緋葷粺閿姣佷簡錛岃屽鏋滀粎浠呮槸鍋滅暀鍦ㄦ湁榪欑鍙兘鎬х殑鎯呭喌涓嬶紝鍒欒鏂規硶涓嶄細琚皟鐢紝渚嬪錛屽綋姝e湪鏄劇ずactivity
A鐨勬椂鍊欙紝鐢ㄦ埛鎸変笅HOME閿洖鍒頒富鐣岄潰錛岀劧鍚庣敤鎴風揣鎺ョ潃鍙堣繑鍥炲埌activity A錛岃繖縐嶆儏鍐典笅activity
A涓鑸笉浼氬洜涓哄唴瀛樼殑鍘熷洜琚郴緇熼攢姣侊紝鏁卆ctivity A鐨刼nRestoreInstanceState鏂規硶涓嶄細琚墽琛?
鍙﹀錛宱nRestoreInstanceState鐨刡undle鍙傛暟涔熶細浼犻掑埌onCreate鏂規硶涓紝浣犱篃鍙互閫夋嫨鍦╫nCreate鏂規硶涓仛鏁版嵁榪樺師
]]>
鐪嬫枃妗o細
Returns an estimated number of bytes that can be read or skipped without blocking for more input.
Note that this method provides such a weak guarantee that it is not very useful in practice.
Firstly, the guarantee is "without blocking for more input" rather than "without blocking": a read may still block waiting for I/O to complete 鈥?the guarantee is merely that it won't have to wait indefinitely for data to be written. The result of this method should not be used as a license to do I/O on a thread that shouldn't be blocked.
Secondly, the result is a conservative estimate and may be significantly smaller than the actual number of bytes available. In particular, an implementation that always returns 0 would be correct. In general, callers should only use this method if they'd be satisfied with treating the result as a boolean yes or no answer to the question "is there definitely data ready?".
Thirdly, the fact that a given number of bytes is "available" does not guarantee that a read or skip will actually read or skip that many bytes: they may read or skip fewer.
It is particularly important to realize that you must not use this method to size a container and assume that you can read the entirety of the stream without needing to resize the container. Such callers should probably write everything they read to a ByteArrayOutputStream and convert that to a byte array. Alternatively, if you're reading from a file, length() returns the current length of the file (though assuming the file's length can't change may be incorrect, reading a file is inherently racy).
The default implementation of this method in InputStream always returns 0. Subclasses should override this method if they are able to indicate the number of bytes available.
]]>
1錛嶣IG-ENDIAN銆丩ITTLE-ENDIAN銆佽窡CPU鏈夊叧鐨勶紝姣忎竴縐岰PU涓嶆槸BIG-ENDIAN灝辨槸LITTLE- ENDIAN銆併侷A鏋舵瀯鐨凜PU涓槸Little-Endian錛岃孭owerPC 銆丼PARC鍜孧otorola澶勭悊鍣ㄣ傝繖鍏跺疄灝辨槸鎵璋撶殑涓繪満瀛楄妭搴忋傝岀綉緇滃瓧鑺傚簭鏄寚鏁版嵁鍦ㄧ綉緇滀笂浼犺緭鏃舵槸澶уご榪樻槸灝忓ご鐨勶紝鍦↖nternet鐨勭綉緇滃瓧 鑺傚簭鏄疊IG-ENDIAN銆傛墍璋撶殑JAVA瀛楄妭搴忔寚鐨勬槸鍦↗AVA铏氭嫙鏈轟腑澶氬瓧鑺傜被鍨嬫暟鎹殑瀛樻斁欏哄簭錛孞AVA瀛楄妭搴忎篃鏄疊IG-ENDIAN銆?/p>
2錛庢墍浠ュ湪鐢–/C++鍐欓氫俊紼嬪簭鏃訛紝鍦ㄥ彂閫佹暟鎹墠鍔″繀鐢╤tonl鍜宧tons鍘繪妸鏁村瀷鍜岀煭鏁村瀷鐨勬暟鎹繘琛屼粠涓繪満瀛楄妭搴忓埌緗戠粶瀛楄妭搴忕殑杞崲錛岃屾帴 鏀舵暟鎹悗瀵逛簬鏁村瀷鍜岀煭鏁村瀷鏁版嵁鍒欏繀欏昏皟鐢╪tohl鍜宯tohs瀹炵幇浠庣綉緇滃瓧鑺傚簭鍒頒富鏈哄瓧鑺傚簭鐨勮漿鎹€傚鏋滈氫俊鐨勪竴鏂規槸JAVA紼嬪簭銆佷竴鏂規槸C/C++紼? 搴忔椂錛屽垯闇瑕佸湪C/C++涓渚т嬌鐢ㄤ互涓婂嚑涓柟娉曡繘琛屽瓧鑺傚簭鐨勮漿鎹紝鑰孞AVA涓渚э紝鍒欎笉闇瑕佸仛浠諱綍澶勭悊錛屽洜涓篔AVA瀛楄妭搴忎笌緗戠粶瀛楄妭搴忛兘鏄疊IG- ENDIAN錛屽彧瑕丆/C++涓渚ц兘姝g‘榪涜杞崲鍗沖彲錛堝彂閫佸墠浠庝富鏈哄簭鍒扮綉緇滃簭錛屾帴鏀舵椂鍙嶅彉鎹級銆傚鏋滈氫俊鐨勫弻鏂歸兘鏄疛AVA錛屽垯鏍規湰涓嶇敤鑰冭檻瀛楄妭搴忕殑闂? 棰樹簡銆?/p>
杞嚜http://www.embest.net/index.php/archives/259